- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-19-2017 07:12 AM
Hi, when a user creates a new form on the related list, I want the product owner to be auto filled with the same value as the product owner on the form they are creating the related form from.
This is the form where the product owner is filled from:
Here you can see the related list below it:
Here is the form that pops up when you click new, I want to auto fill Product Owner with the same value as PO on the main form. They are both referencing the User table.
Any help appreciated!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-19-2017 07:36 AM
Hi Shane,
I've commented a few points below, hope this helps clear up a few things but let me know.
var gr = new GlideRecord('u_gbts_code_release_management');
gr.addQuery('number', current.parent); //change number to sys_id. current.parent will return a sys_id and you need to match like for like
gr.query();
while(gr.next()) {
current.u_approver2 = gr.u_product_owners; //product_owners implies plurality, what sort of field is this?
}
gr.update(); //you haven't changed anything on the glide record so this line is not needed.
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-19-2017 07:19 AM
Hi Shane,
If the requirement is that whenever the a record is added to the code moves table then, if there is a parent record, the product owner from the parent should be populated on the code moves record you can use a before insert business rule on the code moves table.
var gr = new GlideRecord('sys_release_table') //check table name
gr.addQuery('sys_id', current.parent);
gr.query();
while(gr.next()){
current.product_owner = gr.product_owner;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-19-2017 07:27 AM
That's kind of the same as to what I tried, but it didn't seem to work?
Business Rule:
(function executeRule(current, previous /*null when async*/) {
var gr = new GlideRecord('u_gbts_code_release_management');
gr.addQuery('number', current.parent);
gr.query();
while(gr.next()) {
current.u_approver2 = gr.u_product_owners;
}
gr.update();
})(current, previous);
Triggers before insert.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-19-2017 07:36 AM
Hi Shane,
I've commented a few points below, hope this helps clear up a few things but let me know.
var gr = new GlideRecord('u_gbts_code_release_management');
gr.addQuery('number', current.parent); //change number to sys_id. current.parent will return a sys_id and you need to match like for like
gr.query();
while(gr.next()) {
current.u_approver2 = gr.u_product_owners; //product_owners implies plurality, what sort of field is this?
}
gr.update(); //you haven't changed anything on the glide record so this line is not needed.
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-19-2017 07:48 AM
This works perfectly on insert:
(function executeRule(current, previous /*null when async*/) {
var gr = new GlideRecord('u_gbts_code_release_management');
gr.addQuery('sys_id', current.parent);
gr.query();
while(gr.next()) {
current.u_approver2 = gr.u_product_owners;
}
})(current, previous);
Thanks for your help. Product Owner is only a single product owner, I'm not sure why it's named as it is. One more question, is it possible to do this onLoad as opposed to on insert? I imagine a client script and script include are needed?
Edit: I changed it to Display and it seems to work onLoad now!