How to send catalog item variable value to third party

SNOW39
Tera Expert

I have a requirement that when user enters value in the field "code data" and submits the catalog item,the value in the field should be send to Azure.

how can i achieve this? What are the steps.

3 REPLIES 3

SumanthDosapati
Mega Sage
Mega Sage

You can create a rest message and configure third party details in that and call that in catalog item workflow.

OR

Try this script in workflow Run script activity

var value = current.variables.variable_name;// give variable name
	var body = {"variable":value.toString()"};//you can pass any other data if needed
	
	var req = new sn_ws.RESTMessageV2();
	req.setEndpoint("Give end point of azure");
	req.setHttpMethod("POST");
	req.setBasicAuth("username here","password");//give username and password provided by azure
	req.setRequestHeader("Content-Type","application/json");
	req.setRequestBody(JSON.stringify(body));
	
	
	var response = req.execute();
	
	var body1 = response.getBody();
	var status = response.getStatusCode();

 

Mark as correct or helpful if it does.

Regards,

Sumanth

Yashashri
Tera Contributor

Hello Sumanth,

 

I am trying this script with workflow via submitting SR. On task creation I am using the script. Is there any way that I can see test results if it is sending successful transactions before checking on DevOps side ?

Please suggest

USe below script to fetch all variable value.

 

var fld;
var varown = new GlideRecord('sc_item_option_mtom');
varown.addQuery("request_item", 'f131fb821b75d110007fedf2b24bcbc1'); // add your ritm number
varown.query();
while (varown.next())
{
var visible = varown.sc_item_option.item_option_new.visible_summary;
//var question = Packages.com.glideapp.questionset.Question.getQuestion(varown.sc_item_option.item_option_new);//Packages call replaced with line below.
var question = GlideappAbstractChoiceListQuestion.getQuestion(varown.sc_item_option.item_option_new);
question.setValue(varown.sc_item_option.value);
if (question.getLabel() != "" && question.getDisplayValue() !="" && question.getDisplayValue()!='false'&& visible == true)
{
fld +=question.getLabel() + '|' + question.getDisplayValue()+ '~P~';
}
}
gs.log('Variables:'+fld);

 

Finally, send the fld value to the 3rd party as per your consumed url.

Regards,
Suresh.