Custom scripts don't work consistently

Good day

I am struggling with my custom scripts, they are not working all the time.
For instance, I am just doing a custom script that checks variable falls within a list and outputs a Boolean variable.

This works perfectly at the beginning but stops working after a while.
It doesn’t give an error, it just doesn’t activate the custom code anymore.

I have to shutdown Workfusion and start it up again and then the code starts working again.

This is my code:

activecode is a string variable and creditcheck is a Boolean variable

@CustomScriptAction(
    input = ['activecode'],
    output = 'creditcheck'
)

def customScript() {

    if( (activecode) == RString.of("DO") || 
    (activecode) == RString.of("AFR") || (activecode) == RString.of("APR") || (activecode) == RString.of("DON") || 
    (activecode) == RString.of("DP") || (activecode) == RString.of("DRR") || (activecode) == RString.of("IC") || 
    (activecode) == RString.of("IDR") || (activecode) == RString.of("IFR") || (activecode) == RString.of("IPR") || 
    (activecode) == RString.of("JC") || (activecode) == RString.of("JCC") || (activecode) == RString.of("JCN") || 
    (activecode) == RString.of("JDR") || (activecode) == RString.of("LCR") || (activecode) == RString.of("MC") || 
    (activecode) == RString.of("MCN") || (activecode) == RString.of("PAR") || (activecode) == RString.of("SCR") ||
    (activecode) == RString.of("SO") || (activecode) == RString.of("SON") || (activecode) == RString.of("CFR") ||
    (activecode) == RString.of("VCR") || (activecode) == RString.of("FFR") || (activecode) == RString.of("HPR") ||
    (activecode) == RString.of("PPR") || (activecode) == RString.of("BCR") || (activecode) == RString.of("AC") ||
    (activecode) == RString.of("RL") || (activecode) == RString.of("GNR") || (activecode) == RString.of("GDR") ||
    (activecode) == RString.of("RTR") || (activecode) == RString.of("BI") || (activecode) == RString.of("HD") ||
    (activecode) == RString.of("HDN") || (activecode) == RString.of("SFR") || (activecode) == RString.of("DCR") ||
    (activecode) == RString.of("INFR") || (activecode) == RString.of("PLFR") || (activecode) == RString.of("PCR") ||
    (activecode) == RString.of("NIR") || (activecode) == RString.of("CT") || (activecode) == RString.of("DTR") ||
    (activecode) == RString.of("GTR") || (activecode) == RString.of("DKR") || (activecode) == RString.of("ECR") ||
    (activecode) == RString.of("CLR") || (activecode) == RString.of("MFR") || (activecode) == RString.of("PSR") ||
    (activecode) == RString.of("RA") || (activecode) == RString.of("CCR") || (activecode) == RString.of("LDR") ||
    (activecode) == RString.of("CD") || (activecode) == RString.of("MD") || (activecode) == RString.of("DFR") )
{

       creditcheck = RBoolean.fromCanonical('true')

    } else {

       creditcheck = RBoolean.fromCanonical('false')
    }

}

Is there a reason custom actions stop working?

From what I know, I never has such an issue with custom scripts.
However it happened to me quite often that starting a bot takes some time (no idea why, maybe it incorrectly stopped previously) which forced me either to wait long enough or to kill workfusion and restart it.

Your issue reminds me of this problem. Can you put a step before the custom action and check whether this step is reached?

By the way what do you mean with ‘It doesn’t give an error, it just doesn’t activate the custom code anymore.’ ? Does it directly go to the next step ?

Hi, thank you for the response.

i’ve been testing the variable before the custom script.
i use a notepad the type it out, so i can see it.

the variable types out exactly a string that should activate the custom script.
the bot just goes to the next line, the script doesn’t activate at all.

it’s funny because it will work the first time i run it but when i loop back it won’t work.
there is only one input variable that reflects the same.

Hi, thank you for the response.

i’ve been testing the variable before the custom script.
i use a notepad the type it out, so i can see it.

the variable types out exactly a string that should activate the custom script.
the bot just goes to the next line, the script doesn’t activate at all.

it’s funny because it will work the first time i run it but when i loop back it won’t work.
there is only one input variable that reflects the same.

Can you please share a caption of your rpa code please

Hi

i have shared the custom script code i am using above.
or do you mean my whole code, its pretty big. around 900 lines

regards

Caption of your whole code. If it’s too heavy, could you at least make a small example that reproduces the error ?

here is the part of the code. it works perfectly the first time around.
then not again. even force stopping bot won’t change it. I litlerarly have to shut down workfusion fully and start everything up for the codes to work again. there is no error message, it just skips the code. an answer that should come out as true boolean never happens

Thank you for your code. However it is a bit dense. Could you maybe simplify to part that does not work to only 2/3 lines of code so that it is easier to understand the issue. When you do so please also show your recorder variables tab.

Thank you

@CustomScriptAction(
    input = ['activecode'],
    output = 'creditcheck'
)

def customScript() {

    if( (activecode) == RString.of("DO") || (activecode) == RString.of("AFR") )
{

       creditcheck = RBoolean.fromCanonical('true')

    } else {

       creditcheck = RBoolean.fromCanonical('false')
    }

}

good day

here is simplified version of the code, it is a “if” statement if the “activecode” is equal to the string DO or AFR. if found the return a boolean variable of true else false.

the incoming variable shows “DO” as an example, code will work the first time through a whole range of in a while loop.

then when i restart this process, it won’t work any more and i’ll only get False answers.

I don’t see where the code breaks in the example. Could you create a simple RPA program that fails so that I can inspect where the problem comes from?

I tried the following:
image


And get the desired output every single time:
image

Good day

on a small scale test it seems to work, i cannot replicate the error.
but on the big scale it fails. it also continues to fail until i shut down work fusion itself fully.
is there a possibility in that i’m asking too many IFs in the code, like is the cache full. is there a way to clear it?

I’ve now built a very big work around to test for true or false. now once i got a true i have another smaller custom script, this one actually crashes also if the bigger one crashes. Here is how the code looks. it is meant to edit one entry in a table, there is no other function for this that i know of. I run it from studio and it doesn’t crash but in tower it crashes(same as other code).

the code looks like this.

@CustomScriptAction(
    input = ['fullstatement', 'activecode', 'sum1'],
    output = 'fullstatement'
)

def customScript() { 

   fullstatement.put(sum1 + 1,3, activecode) }

before i run this code i had it type out the variables.

activecode = “-LD”
sum1 = 3

in this case it is meant to replace row 3 of column 3 with “-LD” i also type out this one before the code is meant to replace it and it show “LD”. basicly i want “LD” to become “-LD” in the table.

in studio and tower it types out the same variables, tower crashes. it must be noted the codes work perfectly with a fresh start to work fusion, but after one successful run it will continue to crash in tower. even rescheduling with the exact data that was accepted before will make it crash until i shut down workfusion and start it again.

could this be a cache thing or do i need to name each custom action individually?

1 Like

i could make another work around and export the table to excel piece by piece but it will slow down the whole bot down.

i would really like to use custom scripts.

@ivan.swiegers do you have more than 1 custom script with the same name in the same bot task (recording)? If you do, they need to have different names

Good day

yes i do, i have around 6 custom scripts in the process.
how do i rename the scripts?

Good day

i’ve looked at your Msg and feedback and i will try it and get back.
how would i rename this script as an example.
is this acceptable

@CustomScriptAction(
    input = ['fullstatement', 'activecode', 'sum1'],
    output = 'fullstatement'
)

def customReplacecode() { 

   fullstatement.put(sum1 + 1,3, activecode) }
1 Like

Yes, this name is acceptable.
You can use numbers in the name, but it has to start with a letter.

for the moment i can say that this solution worked. i have had multiple runs without a crash now.
all it needed was a name change.

thank you.

2 Likes

Glad it helped @ivan.swiegers

1 Like