on Hold reason

yardenKrispel
Tera Contributor
In every change of the On hold reason field (at that moment even before saving) - the label of the "On hold reason" field is copied to the "Short description" field.

Thank you!
3 REPLIES 3

Peter Bodelier
Giga Sage

Hi @yardenKrispel,

 

Try this script in before Business Rule. Condition = On Hold reason changes:

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

	var short_description = current.getValue('short_description');
	var new_short_description;
	var new_hold_reason = current.getDisplayValue('hold_reason');
	var previous_hold_reason = previous.getDisplayValue('hold_reason');

	if (new_hold_reason && previous_hold_reason ){
		new_short_description = short_description.replace(/\[(.*?)\]/,'['+new_hold_reason+']');
	}
	else if (new_hold_reason && !previous_hold_reason){
		new_short_description = '[' +new_hold_reason + ']' + short_description;
	}
	else if (!new_hold_reason && previous_hold_reason){
		new_short_description = short_description.replace(/\[(.*?)\]/,'');
	}

	current.short_description = new_short_description;
})(current, previous);

 


Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.

Hi!

Unfortunately it doesn't work!

Hi @yardenKrispel,

 

What exactly doesn't work for you? It works like a charm in my instance.


Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.