Work Order to Work Order Task Variables

Gersy
Tera Contributor

Hi from Bonnie Scotland!

I have searched on this subject and attempted to create a Flow using Now Assist, but I am still not seeing the results, so thought I would lean on this group's knowledge - if I may.

 

For the purpose of getting FSM into our orginsation as soon as possible, I have opted to stage implementation, and although a further update will look to use the already populated Asset table for assets, I need to use what we already use within Incidents, and that is a customer table which has assets imported daily (long winded process from before my time, but it works!). So, I have added a few fields from that customer table, to the Work Order - let's call them u_first_one and u_second_one. 

What I need to do is have the data from those fields in the WO, populate into the WOT. 

I have tried NowAssist for a flow, and worded it a few different ways, but the output code seems similar regardless - but it does not populate the task. I have tried this on a few different flows, as I get used to the system, for example 'Initial State' and 'Ready for Dispatch', but nothing seems to make a difference.

Could someone help explain where this needs to be, and if you have an example of the script, I would really appreciate it.

For the above I did have assignment set to manual, but I have changed this now to Auto, as we will not be using Dispatchers as such - I will create rules based on user input on the WO to automatically assign to the relevant assignment group and engineer.

2 REPLIES 2

Mark Manders
Giga Patron

What did you already try? What did the flow execution say? What exactly isn't working? Just those 2 fields, or nothing? How are you creating the tasks? Is this fully OOB or are there adjustments to what is copied to the Tasks?


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

The Task creation is OOB. 

The task is being created by the submission of the WO.

The flow execution under test seemed to report no issues, but when you go to the task, the field is still empty - there was certainly no errors being flagged.

I have tried adding a Work Task Flow using NowAssist, which runs on the event of wo.task.created, to generate the script and it was as follows:

// Server-side Script (Business Rule or Script Include)
// Copies u_slots_position_number from parent Work Order to Work Order Task

(function execute(inputs, outputs) {
	// Ensure this runs on Work Order Task (e.g., 'wm_order_task')
	try {
		// 'current' is available in Business Rule context
		if (!current || !current.u_slots_position_number) {
			// Only proceed if current exists
			if (!current) return;

			// Get parent Work Order reference
			var parentId = current.parent;
			if (!parentId) return; // No parent, nothing to copy

			// Query parent Work Order (e.g., 'wm_order')
			var parentGR = new GlideRecordSecure('wm_order');
			if (!parentGR.get(parentId)) return; // Parent not found

			// Security: Only copy if user can read the field
			if (!parentGR.canRead() || !parentGR.isValidField('u_slots_position_number')) return;

			// Copy value if present
			var parentSlots = parentGR.u_slots_position_number;
			if (parentSlots) {
				current.u_slots_position_number = parentSlots;
			} else {
				// Optionally clear if parent is blank
				current.u_slots_position_number = '';
			}
		}
	} catch (e) {
		// Log error for troubleshooting
		GlideSystem.logError('Error copying u_slots_position_number: ' + e.message);
	}
})(inputs, outputs);