Retrieve special instructions on request via script

Brian Hofmeiste
Kilo Guru

Is there a way to grab special instructions from the request container and apply it to comments of the requested item? For example:

 

current.comments = current.parent_request.special_instructions 

thanks! 

1 ACCEPTED SOLUTION

You shouldn't ever need to do a GR on sc_req_item to retrieve the current record, because the current record is what the workflow is running on.  I added a one line Run Script activity as the first activity following Begin, and this worked for me:

current.comments.setJournalEntry(current.request.special_instructions);

Just using current.comments = didn't work in this case, but I knew the special_instructions were getting picked up correctly by adding a logging line

workflow.info('SI ' + current.request.special_instructions);

then viewing the log via the Log tab on the Workflow Context Related Link on the RITM.  The workflow runs on the sc_req_item table when the record is created, which is after the sc_request (REQ) record is created, so I've never experienced any trouble with retrieving or updating any fields on the RITM or REQ records right off the bat.

 

View solution in original post

6 REPLIES 6

You shouldn't ever need to do a GR on sc_req_item to retrieve the current record, because the current record is what the workflow is running on.  I added a one line Run Script activity as the first activity following Begin, and this worked for me:

current.comments.setJournalEntry(current.request.special_instructions);

Just using current.comments = didn't work in this case, but I knew the special_instructions were getting picked up correctly by adding a logging line

workflow.info('SI ' + current.request.special_instructions);

then viewing the log via the Log tab on the Workflow Context Related Link on the RITM.  The workflow runs on the sc_req_item table when the record is created, which is after the sc_request (REQ) record is created, so I've never experienced any trouble with retrieving or updating any fields on the RITM or REQ records right off the bat.

 

Well Brad... you got me on this one 🙂  I don't know why it wasn't working before but it's working now.  I suspect I had something else breaking the code because your example worked.  Thanks!