General Coding Efficiency Question

To level set, no CIS degree or programming/developer experience outside of starting UiPath a few months ago.

I have a process were I managed to get what I wanted accomplished, but I’m sure it could be done with far less steps. I was just hoping for some insight/feedback/resources to skill up in the area.

Scenario: There’s SQL file with coding & notes. The notes need to be parsed out. One of the dates needs to be updated to the current week’s Wednesday when the job runs on Thursday. The SQL code then needs to be pasted into another application an run.

Below is a screenshot of the workflow that I ultimately built:

Read File Text output = SQLcode

TrimmedSQL = SQLcode.Split("*"c )(0).ToString.Trim

Wednesday = DateTime.Now.AddDays(-1*(7 + (DateTime.Now.DayOfWeek - DayOfWeek .Wednesday)) mod 7).Date

strWednesday = Wednesday.ToString(“yyyy-MM-dd”)

LastWeek = Wednesday.AddDays(-7)

strLastWeek = LastWeek.ToString(“yyyy-MM-dd”)

Replace overwrites strLastWeek with strWednesday


This looks standard (maybe you can put annotations and change activity names to be descriptive of what you are doing for maintainability factors, also, give comments of what you are doing and everything can be put in a parallel activity for better speed {if your system has multiple cores}) apart from the split function that can be put in a single assign statement if you feel like you are using too many assign activities (of course we have ‘Multiple assign’ activity in Uipath latest FTS version) then maybe you could have done thsis -

The above conversion can be written like this in a single assign :slight_smile:

strWednesday = (DateTime.Now.AddDays(-1*(7 + (DateTime.Now.DayOfWeek - DayOfWeek .Wednesday)) mod 7).Date).ToString(“yyyy-MM-dd”)


The above conversion can be seemingly condensed into the following:

strLastWeek = ((DateTime.Now.AddDays(-1*(7 + (DateTime.Now.DayOfWeek - DayOfWeek .Wednesday)) mod 7).Date).AddDays(-7)).ToString(“yyyy-MM-dd”)

I won’t claim that this is ‘optimal’ because instead of converting and keeping it in memory we are using conversion twice but it looks cleaner due to lesser activities and with multiple assign and parallel activity it looks much shorter.

Hope this helped :slight_smile:


Yes it does, thank you. I haven’t done anything with the parallel activities before, I’ll have a look at that as well.

1 Like

Great just drag and drop activities side by side in the parallel scope and it will get executed faster. :slight_smile:

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.