Can you set a workflow stage in a script

Ruth_Porter
Kilo Explorer

Hi there,
Is it possible to set the workflow stage in the script that the activity runs? If so, how woudl such a script look?

Thanks in advance, Ruth

4 REPLIES 4

Mark Stanger
Giga Sage

You can. Workflow stages are really just a specific field being set to a certain value so you just need to set a field value on the record. There's not really much more you can do with it.


Just trying to accomplish the same. Could somebody post a snippet for this?


Ruth_Porter
Kilo Explorer

Thanks for the help Mark but this does not work: the table is sc_req_item and unless I specifically include the stages in the stage field of at elast one activity it does not appear in the widget.

So I tried using a differnt stage field (not recommended acording to the wiki) and then though they show, the last stage nevers gets marked as completed.

This is driving me round the bend so any help gratefully received

Regards, Ruth


ty_roach
Tera Guru

I am trying to do the same exact thing.

In the workflow editor, I use the "Set Values" activity and select my Stage field and set it to its appropriate value. Unfortunately, the "Set Values" activity does not have conditional capabilities, thus I am resorting to try to do this same thing in the "Run Script" activity.

I've asked this same question to the community. I can create a series of if-statements in my script like this:

if (current.stage == "A") {
}
else if (current.stage == "B") {
}
...

and it will conditionally find the correct workflow stage, only I cannot figure out how to set the stage value properly.

Simply saying something like current.stage = "B" does not work. Although the field in the form will show its value as "B" there will actually be two B's, the real B, which my is not, and then this newly assigned B (if that makes sense).

Sooooo...if anyone has some insights here, it would be greatly appreciated.