How to pass a value into workflow

kulshreshtha
Giga Contributor

Hi I have done a very simple workflow which I am trigger using a business rule. Please find below my business rule, workflow.

find_real_file.png

Business rule:

(function executeRule(current, previous /*null when async*/)

{

.........................

...........................

..........................

  var gr = new GlideRecord('wf_workflow');

  gr.addQuery('name', 'Z');

  gr.query();

  if (gr.next()) {

    var wf = new Workflow();

    var workflowId = '' + gr.sys_id;

    var vars = {};

    vars.number =5;

    wf.startFlow(workflowId, current, current.operation, {number: 5});

         

  }

  action.setRedirectURL(current);

})(current, previous);

My aim is to assign a value to a workflow variable. Here if workflow variable which i have named as number =5 i need to get mail with subject YES or else NO. Code in If block of workflow is

answer = ifScript();

  function ifScript() {

          if (workflow.scratchpad.number==5) {

                return 'yes';

          }

        return 'no';

  }

Problem is it is always giving NO message. Can anybody help me to get this concept..

Thanks in advance

1 ACCEPTED SOLUTION

Hi Naman,



Yes its the right method.


Whats the column name. check if you are using the same in your code.


View solution in original post

13 REPLIES 13

Hi Naman,



Yes its the right method.


Whats the column name. check if you are using the same in your code.


so u mean i need to mention column_name and not label


find_real_file.png


So everywhere i need to go for u_number rather than number?


Hi Naman,



Yes you need to use column name not label in all your script.



If your question is answered , please mark my response as correct so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list.


Ya the problem was i was not giving column name. Since working for first time with workflow I did this mistake. Seems silly but took long time to realise.. Thanks