Setting Request item and SCTask short descriptions based on a variable field

Moedeb
Tera Guru

I have been trying to set the short descriptions of both the request item and the resulting task based on a variable field, however nothing so far has worked for me.

I have tried adding business rules, but they never seem to fire, I've tried adding a create task as part of a new workflow, but it just hangs at that stage of the workflow.

I've tried: https://community.servicenow.com/community?id=community_question&sys_id=b9fd87addb9cdbc01dcaf3231f96...

Also: https://community.servicenow.com/community?id=community_question&sys_id=e94ffa69db58dbc01dcaf3231f96...

The variable that I'm using is called:

brief_description - (text line)

I would prefer to simply update the task that is automatically created when the workflow runs and not creating a new workflow to create a task as part of it if possible?

Some really detailed instructions/screenshots would also be very much appreciated lol

Thanks in advance

 

11 REPLIES 11

Alikutty A
Tera Sage

Hello,

This can be easily achieved in your workflow. For Request item, You can set this inside a Run script activity by mapping the required variable as

current.short_description = current.variables.variable_name;

For Tasks you should set this inside the Catalog Task activity under the Advanced checkbox

find_real_file.png

 

Let me know if you are still stuck with it.

Thanks!

Ok, so I have managed to get it to work for the request item, however cannot at all work out where or how to do it for the task short description.

 

The workflow I am using is just a copy of the standard "Item Designer Workflow" (copied so I can add stuff)

I cannot see at all a task creation, however it obviously happens somewhere as a task does get created.

I've also looked in the sub-workflows:

  • Item Designer - Approvals
  • Item Designer - Fulfilment

If you can tell me exactly where then I'd be very grateful thank you

Ohh, This is different. The script to create tasks is inside the 'Create catalog task for series' activity within the 'Item Designer - Fulfilment' workflow. In this case I would suggest you to write a before insert business rule on the sc_task table with the following script in it.

if(current.variables.brief_description != ''){
  current.short_description = current.variables.brief_description;
}

 

Thanks for that, it does appear to be doing something, because the short description in the task is now blank (it was a set text block)

I added to the business rule to make sure that it was working:

(function executeRule(current, previous /*null when async*/) {

	// Add your code here
if(current.variables.brief_description != ''){
  current.short_description = current.variables.brief_description;
	current.description = "Business Rule Ran";
}
})(current, previous);

The description of the task does get updated with the text "Business Rule Ran", however as I said the short description is blank

Can you replace the following line and see if it works?

current.short_description = current.request_item.variables.brief_description;