When record is created in related List, it has to set in the Parent table field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2024 10:40 AM - edited ‎03-22-2024 12:00 AM
Hi Everyone,
Here there are two tables called Model (Parent table) and Packaging Data (Related list).
Here when record is created in the Packaging Data related list. it has to set the AppID value in the AppTrackID field in Model parent table. Please help me with the script, how we can achieve this..
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2024 12:18 PM - edited ‎03-21-2024 12:19 PM
Hi @Munna1,
You can do one of the following:
- Use a relationship with a filter
- Navigate to System Definition > Relationships
- Create a new relationship (or use the existing relationship) and add a query, something like:
current.addQuery('app_id=' + parent.getValue('app_Id'));
- Add the related list (If not already there) and if you create a new Packaging Data record, the field(s) specified above will be automatically populated
- Use a Business Rule
- Not sure how those two records are related but if they are related by a reference record (e.g. parent/child), you can write a before BR on insert
Cheers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2024 10:51 PM
Hi James,
Thanks for your response
But I have tried with this Relationship. But it is not working.
Here Parent /child table are related by a reference field called Model. and I am trying with the Before -Insert BR. But it is not working as expected.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-23-2024 02:08 AM
Hi @Munna1,
I believe you should be creating the BR on the Packaging Data table.
And the script should be something like:
var grd = new GlideRecord('cmdb_model');
grd.get(current.getValue('u_software_model'));
if (grd.isValidRecord()) {
current.setValue('u_apptrack_id', grd.getValue('u_apptrack_id'));
current.setValue('u_app_id', grd.getValue('u_app_id'));
}
Note that this will overwrite the two fields even if the user provides a value for them.
Cheers