Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Use Current in workflow script

maryc
Tera Contributor

Hi,

I have 2 methods within a script activity in the workflow for a catalog. I am trying to call <<current.fieldname>>  and <<current.variables.variablename>> , but the value always comes as null.

If I print those values outside the method, I am able to print the values.

Can we not call Current within a method?

 

Thanks

 

1 ACCEPTED SOLUTION

Ashutosh Munot1
Kilo Patron
Kilo Patron

HI,

 

Try this :

gs.log("@@ first name "+current.variables.requested_for_first_name); 
gs.log("@@ Short desc "+current.description); createRequest(current.description,current.company,current.variables.requested_for_first_name,current.variables.requested_for_last_name,current.variables.address1); 


function createRequest(desc,comp,first,last,address) {
 var restMessage = new sn_ws.RESTMessageV2('Order Request', 'Post'); 
 restMessage.setAuthentication("basic", "Auth"); 
 restMessage.setRequestHeader("Accept","application/json");
  restMessage.setRequestHeader("Content-Type","application/json");
   var addressBilling = {};
    addressBilling.Description =desc; 
    addressBilling.CompanyName = comp; 
    addressBilling.Name_First = first;
     addressBilling.Name_Last = last; 
     addressBilling.StreetAddress_Line1 = address;
      gs.log("addressBilling "+addressBilling) 

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


      }

 

Thanks,
Ashutosh Munot

View solution in original post

9 REPLIES 9

alexbones
Tera Expert

What does your script look like?

maryc
Tera Contributor
gs.log("@@ first name "+current.variables.requested_for_first_name); 
gs.log("@@ Short desc "+current.description); createRequest(current); 


function createRequest(current) {
 var restMessage = new sn_ws.RESTMessageV2('Order Request', 'Post'); 
 restMessage.setAuthentication("basic", "Auth"); 
 restMessage.setRequestHeader("Accept","application/json");
  restMessage.setRequestHeader("Content-Type","application/json");
   var addressBilling = {};
    addressBilling.Description = current.description; 
    addressBilling.CompanyName = current.company; 
    addressBilling.Name_First = current.variables.requested_for_first_name;
     addressBilling.Name_Last = current.variables.requested_for_last_name; 
     addressBilling.StreetAddress_Line1 = current.variables.address1;
      gs.log("addressBilling "+addressBilling) 

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


      }

HI,


Yes sometimes i have seen this situations.

 

But when i see you are passing the current glide record in function as well. 

I think you might not be able to see variables right?


Thanks,
Ashutosh Munot

Yes thats correct