- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2024 08:36 PM
Hi Everyone,
I am trying to display the value on stakeholders table that is currently related list into Project.
Which i want to display the value using client script on this below field.
Can you check this below code ?
function onLoad() {
var PO = new GlideRecord('pm_m2m_project_stakeholder');
PO.addQuery('project');
PO.addQuery('expectationINproject_owner');
PO.query();
if (PO.next()){
g_form.setDisplay('u_project_owner' , PO.stakeholder.user.name.getDisplayValue() );
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-26-2024 12:31 AM
Hi @Jeck Manalo
Yeah....Its best practice now a days to use flow designer instead of business rule on table....indeed.
Fix script : It is server side script similar to business rule to update records in bulk manner which you can run on demand.
E.g., If you want to update the state of incident to closed which are older that 6 months like wise...
another example with screenshot :
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-26-2024 01:36 AM
I figured out that I just need to reconfigure my works on flow designer.
its now working 🙂 but thank you for those idea it's help a lot.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2024 11:58 PM
Hi @Jeck Manalo
Okh got it...!!
You can write Business rule on 'pm_m2m_project_stakeholder' table with condition
Script :
(function executeRule(current, previous /*null when async*/) {
/*1. Get the value of project */
var getProject = current.getValue('project'); //will get sys_id of project record
/*2. Get value of Stakeholder */
var getStakeholder = current.getValue('stakeholder');
/*3.Glide record on Project table */
var grProject = new GlideRecord('pm_project');
grProject.addQuery('sys_id',getProject);
grProject.query();
if(grProject.next()){
/* 3.1 Update product owner with stakeholder */
grProject.setValue('u_product_owner',getStakeholder);
grProject.update();
}
/* you can improve your code as per your need */
})(current, previous);
**Note : This will run for new records or if it gets updated.
For existing record you can do it with fix script.
Hope this helps...!!
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-26-2024 12:07 AM
I think its just similar on my flow designer process which will update the field once the stakeholders created/updated.
Stakeholders data is already there since it was just transferred to project table so there no need to update/create new data.
Can you tell me what fix script you mean ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-26-2024 12:31 AM
Hi @Jeck Manalo
Yeah....Its best practice now a days to use flow designer instead of business rule on table....indeed.
Fix script : It is server side script similar to business rule to update records in bulk manner which you can run on demand.
E.g., If you want to update the state of incident to closed which are older that 6 months like wise...
another example with screenshot :
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-26-2024 01:36 AM
I figured out that I just need to reconfigure my works on flow designer.
its now working 🙂 but thank you for those idea it's help a lot.
