What is the Best Way to Reduce Several Plain Spaces

Suppose you have a word file and it is translated to raw an Excel export or Text by a robot system. The file had tabs or indentations and you have put white spaces in those spots.

Now these white spaces need to be reduced into a single space. Here is an example:

From: This…is…a…test.

To: This is a test.

You have a simple way and that is to use Regex.

Here is a Regex operation in the following which eliminates multiple spaces and creates a single space.

<p>myString = Regex.Replace(myString, "\s+", "
")</p>

How to Compare Date and Time

If you want to compare the Date & Time with Current time while trying to get the record which was opened in the past 24 hours and get the difference is Hrs, you need to do the following:

Convert the 2 dates of each string row to date time format.

Let ‘date1’ & ‘date2’ be the ‘DateTime’ variables for each row activity,

Date1 =Datetime.ParseExact(row(&quot;Date and Time&quot;).ToString.Trim(),&quot;MM/dd/yyyy
HH:mm:ss&quot;,System.Globalization.CultureInfo.InvariantCulture)&lt;/p&gt;

and

Date2=Datetime.ParseExact(row("Updated date and Time").ToString().Trim(),"MM/dd/yyyy HH:mm:ss",System.Globalization.CultureInfo.InvariantCulture)

Create a variable with ‘Timespan’ type. Let it be ‘TimeDiff’.

Assign TimeDiff=date2- date1

You can get the time difference in days, hours, minutes, seconds… by using TimeDiff.TotalDays, TimeDiff.TotalHours etc.

How to Fetch the Output from Powershell Script and Convert it to String

The issue seems big but the solution is simple. First, when you try to run the script to store it as a string, you get the following error:

‘Check Outlook Failed.’

‘Object reference not set to an instance of an object.’

In order to run the powershell script and bring the output into a string variable, you need to do the following:

 Use “Run power shell script” only and no other PowerShell.

It will work fine with the following script:

$ProcessActive = Get-Process outlook -ErrorAction SilentlyContinue

if ($ProcessActive -eq $null) {

return $a = “False”

} else {

return $a = “True”

}

How to Fetch Data from the Queue in the ReFramework

When you add data in the Queue and would like to fetch this data in the re-framework, you should do the following:

The process is automatic. The ReFramework gets the data from the Queue. In fact, the Queue is specified in the configuration sheet. The specification is by default in the GetTransactionData.xaml workflow.  

Check in your system to find that a key is used in the dictionary named “OrchestratorQueueName” and you will find the value of that key in the Settings area of the configuration file. This is the file called ReFramework.

How to Read an Attachment in an Email

Reading an attachment in an incoming email needs that you through the UI of the email application. In outlook, go to the email, click the attachment then click open and not save.  If the attachment is in PDF, you can attach the window at the place where PDF opens. Add this filter in the outlook activity: “[Attachment]=’*.pdf’”

To filter the mails with a specific word inside them, you need to search for that word in the attachments one by one. If this is a long and slow process, save the attachments and read the files to find the word.  After this, you can delete them.

How to Select from Strong Array

When you have a String array and you want to select elements till the end and make a returning array or list with those elements, you need to follow the function given below:

You can suppose an array like given here but you want a new array which starts from third element and takes everything:

arrstr = {“1”,“2”,“3”,“4”,“5”,“6”}

arrstr is a array of string variable

arroutput = arrstr.Skip(2)

arroutput is a system.collections.generic.Ienumerable variable

The above process will leave the first two elements from the array and choose all the rest elements.

<Activity mc:Ignorable="sap sap2010 sads" x:Class="Main" mva:VisualBasic.Settings="{x:Null}" sap2010:WorkflowViewState.IdRef="Main_1"
 xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities"
 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
 xmlns:mva="clr-namespace:Microsoft.VisualBasic.Activities;assembly=System.Activities"
 xmlns:s="clr-namespace:System;assembly=mscorlib"
 xmlns:sads="http://schemas.microsoft.com/netfx/2010/xaml/activities/debugger"
 xmlns:sap="http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation"
 xmlns:sap2010="http://schemas.microsoft.com/netfx/2010/xaml/activities/presentation"
 xmlns:scg="clr-namespace:System.Collections.Generic;assembly=mscorlib"
 xmlns:sco="clr-namespace:System.Collections.ObjectModel;assembly=mscorlib"
 xmlns:ui="http://schemas.uipath.com/workflow/activities"
 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <TextExpression.NamespacesForImplementation>
    <sco:Collection x:TypeArguments="x:String">
      <x:String>System.Activities</x:String>
      <x:String>System.Activities.Statements</x:String>
      <x:String>System.Activities.Expressions</x:String>
      <x:String>System.Activities.Validation</x:String>
      <x:String>System.Activities.XamlIntegration</x:String>
      <x:String>Microsoft.VisualBasic</x:String>
      <x:String>Microsoft.VisualBasic.Activities</x:String>
      <x:String>System</x:String>
      <x:String>System.Collections</x:String>
      <x:String>System.Collections.Generic</x:String>
      <x:String>System.Data</x:String>
      <x:String>System.Diagnostics</x:String>
      <x:String>System.Drawing</x:String>
      <x:String>System.IO</x:String>
      <x:String>System.Linq</x:String>
      <x:String>System.Net.Mail</x:String>
      <x:String>System.Xml</x:String>
      <x:String>System.Xml.Linq</x:String>
      <x:String>UiPath.Core</x:String>
      <x:String>UiPath.Core.Activities</x:String>
      <x:String>System.Windows.Markup</x:String>
      <x:String>System.Collections.ObjectModel</x:String>
    </sco:Collection>
  </TextExpression.NamespacesForImplementation>
  <TextExpression.ReferencesForImplementation>
    <sco:Collection x:TypeArguments="AssemblyReference">
      <AssemblyReference>System.Activities</AssemblyReference>
      <AssemblyReference>Microsoft.VisualBasic</AssemblyReference>
      <AssemblyReference>mscorlib</AssemblyReference>
      <AssemblyReference>System.Data</AssemblyReference>
      <AssemblyReference>System</AssemblyReference>
      <AssemblyReference>System.Drawing</AssemblyReference>
      <AssemblyReference>System.Core</AssemblyReference>
      <AssemblyReference>System.Xml</AssemblyReference>
      <AssemblyReference>System.Xml.Linq</AssemblyReference>
      <AssemblyReference>PresentationFramework</AssemblyReference>
      <AssemblyReference>WindowsBase</AssemblyReference>
      <AssemblyReference>PresentationCore</AssemblyReference>
      <AssemblyReference>System.Xaml</AssemblyReference>
      <AssemblyReference>UiPath.UiAutomation.Activities</AssemblyReference>
      <AssemblyReference>UiPath.System.Activities</AssemblyReference>
      <AssemblyReference>System.ServiceModel</AssemblyReference>
      <AssemblyReference>System.ValueTuple</AssemblyReference>
      <AssemblyReference>UiPath.Excel</AssemblyReference>
      <AssemblyReference>UiPath.Mail</AssemblyReference>
      <AssemblyReference>System.Collections.Immutable</AssemblyReference>
      <AssemblyReference>UiPath.Word</AssemblyReference>
    </sco:Collection>
  </TextExpression.ReferencesForImplementation>
  <Sequence sap2010:WorkflowViewState.IdRef="Sequence_1">
    <Sequence.Variables>
      <Variable x:TypeArguments="s:String[]" Default="[{&quot;one&quot;,&quot;two&quot;,&quot;three&quot;,&quot;four&quot;,&quot;Five&quot;}]" Name="arrOriginal" />
      <Variable x:TypeArguments="s:String[]" Name="arrNew" />
      <Variable x:TypeArguments="x:Int32" Default="2" Name="intStartIndex" />
    </Sequence.Variables>
    <Assign sap2010:WorkflowViewState.IdRef="Assign_2">
      <Assign.To>
        <OutArgument x:TypeArguments="s:String[]">[arrNew]</OutArgument>
      </Assign.To>
      <Assign.Value>
        <InArgument x:TypeArguments="s:String[]">[new string(arrOriginal.Length - intStartIndex-1) {}]</InArgument>
      </Assign.Value>
    </Assign>
    <ui:InvokeCode ContinueOnError="{x:Null}" Code="Array.Copy(arrOriginal,intStartIndex,arrNew, 0,arrOriginal.Length - intStartIndex)" DisplayName="Invoke Code" sap2010:WorkflowViewState.IdRef="InvokeCode_1">
      <ui:InvokeCode.Arguments>
        <InOutArgument x:TypeArguments="s:String[]" x:Key="arrOriginal">[arrOriginal]</InOutArgument>
        <InOutArgument x:TypeArguments="s:String[]" x:Key="arrNew">[arrNew]</InOutArgument>
        <InArgument x:TypeArguments="x:Int32" x:Key="intStartIndex">[intStartIndex]</InArgument>
      </ui:InvokeCode.Arguments>
    </ui:InvokeCode>
    <ui:ForEach x:TypeArguments="x:Object" CurrentIndex="{x:Null}" DisplayName="For Each" sap2010:WorkflowViewState.IdRef="ForEach`1_2" Values="[arrNew]">
      <ui:ForEach.Body>
        <ActivityAction x:TypeArguments="x:Object">
          <ActivityAction.Argument>
            <DelegateInArgument x:TypeArguments="x:Object" Name="item" />
          </ActivityAction.Argument>
          <Sequence DisplayName="Body" sap2010:WorkflowViewState.IdRef="Sequence_3">
            <ui:MessageBox Caption="{x:Null}" ChosenButton="{x:Null}" Buttons="Ok" DisplayName="Message Box" sap2010:WorkflowViewState.IdRef="MessageBox_3" Text="[item.ToString]" TopMost="True" />
          </Sequence>
        </ActivityAction>
      </ui:ForEach.Body>
    </ui:ForEach>
    <sads:DebugSymbol.Symbol>dz5DOlxVc2Vyc1xhdm5pc2guZ3VwdGFcRGVza3RvcFxVaVBhdGggVHJhaW5pbmcgTVxUZXN0XE1haW4ueGFtbA9AA2IOAgEBQjZCjwECAQNEM0Q2AgECRgVNDgIBEk4FVBUCAQtVBWASAgEESzJLZwIBFUgzSDsCARNRRFFMAgEQUElQVgIBDlJFUlQCAQxVkAFVmgECAQlbC10WAgEFXA1cxQECAQZcogFcswECAQc=</sads:DebugSymbol.Symbol>
  </Sequence>
  <sap2010:WorkflowViewState.ViewStateManager>
    <sap2010:ViewStateManager>
      <sap2010:ViewStateData Id="Assign_2" sap:VirtualizedContainerService.HintSize="352.666666666667,62" />
      <sap2010:ViewStateData Id="InvokeCode_1" sap:VirtualizedContainerService.HintSize="352.666666666667,164" />
      <sap2010:ViewStateData Id="MessageBox_3" sap:VirtualizedContainerService.HintSize="314,58.6666666666667" />
      <sap2010:ViewStateData Id="Sequence_3" sap:VirtualizedContainerService.HintSize="336,182.666666666667">
        <sap:WorkflowViewStateService.ViewState>
          <scg:Dictionary x:TypeArguments="x:String, x:Object">
            <x:Boolean x:Key="IsExpanded">True</x:Boolean>
          </scg:Dictionary>
        </sap:WorkflowViewStateService.ViewState>
      </sap2010:ViewStateData>
      <sap2010:ViewStateData Id="ForEach`1_2" sap:VirtualizedContainerService.HintSize="352.666666666667,321.333333333333" />
      <sap2010:ViewStateData Id="Sequence_1" sap:VirtualizedContainerService.HintSize="374.666666666667,751.333333333333">
        <sap:WorkflowViewStateService.ViewState>
          <scg:Dictionary x:TypeArguments="x:String, x:Object">
            <x:Boolean x:Key="IsExpanded">True</x:Boolean>
          </scg:Dictionary>
        </sap:WorkflowViewStateService.ViewState>
      </sap2010:ViewStateData>
      <sap2010:ViewStateData Id="Main_1" sap:VirtualizedContainerService.HintSize="414.666666666667,831.333333333333" />
    </sap2010:ViewStateManager>
  </sap2010:WorkflowViewState.ViewStateManager>
</Activity>

How to Add Robot to Trial Version Orchestrator

Have to installed trial version Orchestrator 2018.4.3 for you and tried to add robot option but failed to do so?

In this case, you just do not use the trial version. Better if you use the Community edition. This will allow you to add robot to demo orchestrator in UiPath.4.

The good news is that Orchestrator Community Edition is free of charges and license.  You get the licenses right after you provision your environment.

Use https://platform.uipath.com/ URL and create your work environment. Here you can find the latest version of the orchestrator. Don’t register your device with any enterprise and the edition will work.  

How to Create a Custom Namespace and Import it

If you are a new user of UIPath and face an issue when you try to create a custom namespace and import it, but failing in the process, try the following steps:

Choose c# Class Library

Add references system.activities and system.componentModel

Write the code that you want to execute

Define the input and output parameters

Build your solution

Go to the holding folder and open bin-folder

Open the NuGet explorer and create new library and add the DLL by choosing the add existing option.

Click to write and change the title of the package

Save the file with the desired title and copy the file(.nupckg extension) to the path C:\Users\><user>\AppData\Local\UiPath\app-18.4.0\Packages

Open UiPath and search for the name.

Then, click install. Now, you can execute the code giving the inputs.

How to Download SAP Webservice in UiPath Using SOAP Request Activity

Are you interested to download SAP Webservice in UiPath using SOAP Request activity? Are you are getting the following error?

 “There was an error downloading”

You can try to do the same act with the newest version of the activity package. But, in case here also you face an issue that you are unable to update to version 1.4. and get the following message:

“Unable to resolve dependency ‘Microsoft.CSharp (>=4.3.0)’ “

Add the following feed:

Here it should definitely work but in case (and it is rare) you are still unable to get it, contact the support team here:

https://www.uipath.com/company/contact-us/contact-technical-support

How to Save Pages with a Number/Letter from URL

If you are trying to save pages from the link:

https://picsum.photos/1024/1024/?random

And you want to save the filename with the number mentioned in the URL, you can use the following method:

Test (3) (2).xaml (31.7 KB)

For this, if you click the activity and select right side mouse button under input in properties in order to save image, the image is saved as download.jpeg. So, if that makes a perfect saving choice go for it otherwise you can use the above given link: Test (3) (2).xaml (31.7 KB) and it will help you to save the image with the number or letter added in the URL; for example, x.jpeg.