Is it possible to retrive record producer variable data after the record has been created?

Joshua Cassity
Kilo Guru

Our team uses record producers to create standard and normal changes from our service portal. I'm curious if after that process has taken place, are those record producer variables still able to be accessed to use in decision making?

Ex. Let's say we had a record producer asking the following questions:

1. "Do you enjoy soccer?" - u_soccer (Yes/No)

2. "Do you enjoy golf?" - u_golf (Yes/No)

Now let's say that I mapped the responses to the description field for whomever is working the change in question to see how they answered; However, if they answered 'Yes' to question 1, I'd like to kickoff a specific task to our soccer division to contact the user for a more targeted conversation.

Is it even possible for me to dive into the record producer's variables / responses to know that or would I have to make some kind of hidden field on the Change form 'Soccer' (Yes/No) and then set that field on the record that was created to determine that? I'm really hoping that I don't have to generate hidden fields because in alot of our change processes we want to use this kind of decision making.

Thanks.

1 ACCEPTED SOLUTION

What's the error message say?



Your if activity condition script should look like this:



answer = ifScript();



function ifScript() {


  if (current.variables.u_database_retire == 'Yes') {


  return 'yes';


  }


  return 'no';


}



find_real_file.png


View solution in original post

14 REPLIES 14

Abhinay Erra
Giga Sage

Joshua,



  You can pass the producer variables as parameters to the URL and access them from the client script on the target table.


Chuck Tomasi
Tera Patron

Hi Joshua,



You can access the record producer variables just like any other variables from script by using



<gliderecord>.variables.<variablename>



Here's a simple example I did on one of the OOB incident record producers.



gs.debug('u_checkbox=' + inc.variables.u_checkbox);



Scriptable Service Catalog Variables - ServiceNow Wiki


So let's say instead of an incident, we're making a change from the record producer but aren't necessarily putting that record producer variable's data within the change form but doing an IF check in the workflow attached to that change to kick off a task.



So I would do the following for the IF check in the workflow activity?  



if (change.variables.u_soccer == 'Yes')


        return yes;


else return no;



The opposite of that would be 'current.variables.<variable name>' would be pulling from the actual record that was generated?


Minor change Joshua...



if (current.variables.u_soccer == 'Yes')


        return yes;


else


      return no;



Assuming the variable is holding a "Yes" or "No" string value. If it is a true or false, your if statement needs to be updated accordingly.



Yes, you can access your variables from the workflow the same as any other script.