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

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

You shouldn't pass current as a variable and receive it as current. Just use the below code, since current will be available globally in the workflow.

 

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


function createRequest() {
 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 Sanjivmeher, I tried it and still no luck.

 

Thanks

It should work fine. Do you see any errors in system log

Ashutosh Munot1
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

Jack
Tera Guru

Hi maryc,

Could you check the workflow properties is setting correct?

(Just want to make sure the workflow's table = sc_req_item)

find_real_file.png