0 votes
1 view
in RPA by (5.4k points)

So I have some code inside a code-stage in BP and it works.

The problem is that it is clunky, long and fragile. I would like to know how could I maybe use a class/es in BP to refactor this code into something more concise and scalable, without having to write an external class-library and then refer to it (this is not so easy to do in my environment).

I know it is possible to write methods using the Global Code tab, but could I write an abstract class there? and where would the sub-classes go? How about interfaces? Apologies if this is too basic, I could not find anything previous to guide me on this. Any help or pointers are appreciated, thank you.

The code is a basic decision stage that uses input from data item "Main_Segment" and uses local (private) variables "parcel_label" and "found" to output some static values into BP data items "Parcel_Label" and "Found".

(BP Data Item) Found = (Local variable) found

(BP Data Item) Parcel_Label = (Local variable) parcel_label

(BP Data Item) Main_Segment = (Local variable) segdescript

string segdescript = Main_Segment; found = false; parcel_label = ""; if (segdescript.Contains("Segment 001") || segdescript.Contains("Segment 101")) { found = true; //if first condition is met, assign value of true to "found". if (found = true) //as "found" is now true, the assignment below is carried out. { parcel_label = "Parcel0000"; } } //and again... if (segdescript.Contains("Segment 002") || segdescript.Contains("Segment 202")) { found = true; if (found = true) { parcel_label = "Parcel1111"; } } //and again another 97 times...zzz

1 Answer

0 votes
by (9.5k points)

yes, it is possible  to write abstract classes and any number of child classes and interfaces, but they all have to be written on top of each other inside the Global Code tab of the initialise page. Then any of these child classes can be instantiated from individual code stages throughout the project.

Related questions

0 votes
1 answer
0 votes
0 answers
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...