Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Displaying value into Field using Client Script.

Jeck Manalo
Tera Guru

 

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 ?

JeckManalo_0-1706243553277.png

 

JeckManalo_1-1706243667988.png

 

 

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() );

}
}

2 ACCEPTED SOLUTIONS

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 :

VishalBirajdar_0-1706257804034.png

 

 

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates

View solution in original post

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.

 

JeckManalo_0-1706261782257.png

 

View solution in original post

13 REPLIES 13

You can indicate condition(s) for BR to run under When to Run tab. No need to run Query.

I think if I create BR it's just the same on my flow designer. When someone update the record then it will show on the field.

 

But as per requirement .

 

The record on stakeholders is just tranferred from demand into project. So no need to insert/update the record on the stakeholders since its already there. Which is not showing using flow designer since its need to create/update the record before it will appear on the field and I think this is similar on your suggestion for BR.

 

That is why I want to populate the record using client script. Any ideas ?

JeckManalo_0-1706251873546.png

 

Hello @Jeck Manalo 

 

If my understanding is correct then ,

 

1. There is custom 'u_project_owner' field on 'pm_project' table (what is the type of this custom field ..??)

2. In related list of there is tab for stakeholders (pm_m2m_project_stakeholder) 

like below -- 

 

VishalBirajdar_0-1706253936167.png

 

So you need to populate name of stakeholders related to Project to be displayed on 'u_product_owner' field which is present on 'pm_project' form...??

 

 

 

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates

yes, you are correct its a custom field created by me.

all i need is to get the record on stakeholders that function is Project Owner.

 

type is "reference" for u_product_owner.

 

So you need to populate name of stakeholders related to Project to be displayed on 'u_product_owner' field which is present on 'pm_project' form...?? - yes correct, there is a different view that will show the 'u_project_owner'.