- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi All,
I need to auto populate Assignment group in "asset reclamation task" based on the Requested for location managed by group.
This asset reclamation request are raised from a record producer.
Can some one help me to understand on how to implement this requirement.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
Hi @Arun Priya ,
There are two ways to achieve this
1) You can created after insert BR for the "asset reclamation task" and then check for the requested by location and based on that you can populate the assignment group.
Script:
(function executeRule(current, previous /*null when async*/) {
// Get Requested For user's location
var requestedFor = current.u_requested_for; // Replace with your actual field
var userGR = new GlideRecord('sys_user');
if (userGR.get(requestedFor)) {
var locationSysId = userGR.location; // Reference field
// Look up group managing this location
var locationGR = new GlideRecord('cmn_location');
if (locationGR.get(locationSysId)) {
var managedByGroup = locationGR.u_managed_by_group; // Replace with your actual field name
if (managedByGroup) {
current.assignment_group = managedByGroup;
}
}
}
})(current, previous);
2) You can use On submit catalog client script with similar logic.
After submitting the record it will auto set the field with the group
If this helped to answer your query, please mark it helpful & accept the solution.
Thanks
Siddhesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
@Arun Priya , Till the time your record producer makes a record for the "Asset Reclamation task Table" which you have used in the Assignment rule , there won't be a problem if "Assignment Group" field is not present on your record producer form.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
@Arun Priya Yes. But the Best practice for auto-populating Assignment Group is by using Assignment Rules.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
Hi @Arun Priya ,
There are two ways to achieve this
1) You can created after insert BR for the "asset reclamation task" and then check for the requested by location and based on that you can populate the assignment group.
Script:
(function executeRule(current, previous /*null when async*/) {
// Get Requested For user's location
var requestedFor = current.u_requested_for; // Replace with your actual field
var userGR = new GlideRecord('sys_user');
if (userGR.get(requestedFor)) {
var locationSysId = userGR.location; // Reference field
// Look up group managing this location
var locationGR = new GlideRecord('cmn_location');
if (locationGR.get(locationSysId)) {
var managedByGroup = locationGR.u_managed_by_group; // Replace with your actual field name
if (managedByGroup) {
current.assignment_group = managedByGroup;
}
}
}
})(current, previous);
2) You can use On submit catalog client script with similar logic.
After submitting the record it will auto set the field with the group
If this helped to answer your query, please mark it helpful & accept the solution.
Thanks
Siddhesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
I tried this business rule after insert it is not working. The backend variable of requested for and business rule is attached in screenshot.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
It's After business rule might you need to use the current.update(); so the value will be set in the field.