How do I know current REQUEST number while Workflow is executing on sc_req_item table?

Rajanmehta
Mega Guru

Hello 

 

We are on Jakarta. 

I have Workflow executing on Request Item. (sc_req_item) and is generating a REQ and RITM. 

I found out that current.number will give me RITM number. 

How can I find corresponding  REQ number for the existing Workflow in progress? 

Please advise.

 

Thanks,

Rajan Mehta

 

1 ACCEPTED SOLUTION

Mike Patel
Tera Sage

you can use current.request

to get number you can do current.request.getDisplayValue()

View solution in original post

11 REPLIES 11

Hi Mike ,

Im using run script to create incident.

var gr = new GlideRecord('incident');
gr.initialize();
gr.short_description = 'Mobile Device Troubleshooting';
gr.short_description += ' - ' + current.number.getDisplayValue();
gr.short_description += ' - ' +current.request.requested_for.getDisplayValue() ;
gr.parent = current.request;
gr.setWorkflow(false);
gr.setUseEngines(false);
gr.insert();

 

This is the run script in the beginning,

current.short_description = 'Hardware request';
current.short_description += ' - '+'Mobile Device';
current.short_description += ' - ' +'Mobile Phone';
current.short_description += ' - ' +current.request.requested_for.getDisplayValue() ;
current.short_description += ' - ' +current.variables.region ;
current.work_notes += ' - ' +current.request;// Isn't working..

 

I would like to update REQ and RITM number in INCIDENT work notes when it's created.

Please suggest something.

You need something like

var gr = new GlideRecord('incident');
gr.initialize();
gr.short_description = 'Mobile Device Troubleshooting';
gr.short_description += ' - ' + current.number.getDisplayValue();
gr.short_description += ' - ' + current.request.requested_for.getDisplayValue();

var notes = "Request Number: " + current.request.getDisplayValue();
notes += "\nRequested Item: " + current.number;
gr.work_notes = notes;

gr.parent = current.request;
gr.setWorkflow(false);
gr.setUseEngines(false);
gr.insert();

Awesome this worked.

Thank you so much.

 

Now can you help me to update the Incident number in both REQ and RITM please?

 

try below

var gr = new GlideRecord('incident');
gr.initialize();
gr.short_description = 'Mobile Device Troubleshooting';
gr.short_description += ' - ' + current.number.getDisplayValue();
gr.short_description += ' - ' + current.request.requested_for.getDisplayValue();

var notes = "Request Number: " + current.request.getDisplayValue();
notes += "\nRequested Item: " + current.number;
gr.work_notes = notes;

gr.parent = current.request;
gr.setWorkflow(false);
gr.setUseEngines(false);
var id = gr.insert();

var ir  = new GlideRecord('incident');
ir.get(id);
var INC = "Incident number: " + ir.number;

current.work_notes =  INC;

var reqParent = current.request.getRefRecord();
reqParent.work_notes = INC;
reqParent.update();

Works perfect.

Thank u so much..

But some line in this code is updating REQ number in RITM work notes.

I  don't want that.

I'm unable to figure out which line is that..