- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2023 05:39 AM
Hi,
I need to add assignment group field in Transfer order line task form and i need to auto populate that assignment group value with the transfer order form of "To stockroom " assignment group value.
Please help me .
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2023 08:00 PM
Hi @bhargavi143
You can put a Try Catch in the function to see whether it's able to catch the error or not. Use gs.info() to log the system log.
Something like this.
findAndCreateTask: function(modelCategorySysId, stage) {
try {
var transferOrderLine = current.sys_id;
var transferOrder = current.transfer_order;
var modelCategoryGR = this.findModelCategory(modelCategorySysId, stage);
// Create task for the found model category
if (!gs.nil(modelCategoryGR.getUniqueValue())){
this.createTask(modelCategoryGR, transferOrderLine, transferOrder);
}
} catch (e) {
gs.info('findAndCreateTask - error: ' + e);
}
},
If it still not prints any error, you can mark a breakpoint there and open the Script Debugger tab.
Start Debugging and you will see all the output in details steps by steps.
After all, if it's still blocked you to figure out the root cause, just simply use the first approach instead => Perform the second update with an Async Business Rule.
Cheers,
Tai Vu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2023 08:03 PM
Hi @bhargavi143 ,
After thoroughly examining the TOL and TOLT generation script, I've discovered that the OOTB script process is such that the TOL remains in a pending state until the TOLT is completely generated. This explains why any dot-walking in TOL will return nothing, as the TOL has not yet been fully created. (I have no idea why it's been implemented that way)
You can consider two potential solutions that I've identified,
1. Implement an Async Business Rule, allowing for a pending time to update assignment groups once TOL and TOLT have been completely generated.
Sample below.
2. Modify the OOTB script.
The creation of TOLT is managed through functions findAndCreateTask and createTask in the script include TransferOrderLineTemplateTaskAPI.
So, you can adjust to add an additional parameter for the Transfer Order, followed by a query to retrieve the Assignment Group.
Sample below. (change it at your own risk)
Cheers,
Tai Vu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2023 03:34 AM
Hi Tai,
Thanks for your reply.
But the above changes i made in my instance in TransferOrderLineTemplateTaskAPI script include , after the completion of Transfer order line form its not creating tasks.
Please check the below screen shot
Thanks
Bhargavi.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2023 05:28 AM
Hi @bhargavi143
Both approaches work pretty well per my check.
Can you help to share your changed script to have more inside what have you done?
Below are 2 functions from my modification.
findAndCreateTask: function(modelCategorySysId, stage) {
var transferOrderLine = current.sys_id;
var transferOrder = current.transfer_order;
var modelCategoryGR = this.findModelCategory(modelCategorySysId, stage);
// Create task for the found model category
if (!gs.nil(modelCategoryGR.getUniqueValue()))
this.createTask(modelCategoryGR, transferOrderLine, transferOrder);
},
createTask: function(modelCategoryTemplateTaskGr, transferOrderLine, transferOrder) {
// Check if a task already exists for a selected model category, stage and TOL
var tolTemplateTaskGr = new GlideRecord('alm_transfer_order_line_task');
tolTemplateTaskGr.addQuery('stage', modelCategoryTemplateTaskGr.stage);
tolTemplateTaskGr.addQuery('model_category', modelCategoryTemplateTaskGr.model_category);
tolTemplateTaskGr.addQuery('transfer_order_line', transferOrderLine);
tolTemplateTaskGr.query();
if (!tolTemplateTaskGr.hasNext()) {
// Create task
tolTemplateTaskGr.initialize();
tolTemplateTaskGr.short_description = modelCategoryTemplateTaskGr.task_name;
tolTemplateTaskGr.order = modelCategoryTemplateTaskGr.order;
tolTemplateTaskGr.stage = modelCategoryTemplateTaskGr.stage;
tolTemplateTaskGr.model_category = modelCategoryTemplateTaskGr.model_category;
tolTemplateTaskGr.transfer_order_line = transferOrderLine;
tolTemplateTaskGr.template_task = modelCategoryTemplateTaskGr.sys_id;
var grTO = new GlideRecord('alm_transfer_order');
if(grTO.get(transferOrder)){
tolTemplateTaskGr.assignment_group = grTO.to_stockroom.assignment_group;
}
var tolTaskSysId = tolTemplateTaskGr.insert();
return tolTaskSysId;
}
return null;
},
Cheers,
Tai Vu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2023 05:41 AM
Hi Tai,
Bhargavi.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2023 05:45 AM
Hi @bhargavi143
Let's changes this line
From
this.createTask(modelCategoryGR, transferOrder,transferOrderLine);
To
this.createTask(modelCategoryGR, transferOrderLine, transferOrder);
Cheers,
Tai Vu