current record value client script not on the g_form

mrswann
Kilo Guru

from the sc_task table, I have the following:

function onLoad(){

  var reqitem = g_form.getReference('request_item');

  //alert(reqitem.cat_item);

  if (reqitem.cat_item == ('hardcodedsysidpleasedontshootme') || reqitem.cat_item == ('ipromisetomovethistoasysproperty'))

  {

so I know from the Task, I can get the request_item as it is on the form and from that reference I can get the cat_item

But up a level, if I want to get the cat_item from the sc_req_item itself !! It is not present on the form so how I can access it?

Should I just add the item to the form?

1 ACCEPTED SOLUTION

ccajohnson
Kilo Sage

I have found that if a field is not available on the form it is not found using g_form methods. You could make the field available on the form, then create a UI Policy that hides it since it probably is not needed on the sc_req_item form. Then your g_form methods will work.



Let us know if you are still unsuccessful,


View solution in original post

6 REPLIES 6

ccajohnson
Kilo Sage

I have found that if a field is not available on the form it is not found using g_form methods. You could make the field available on the form, then create a UI Policy that hides it since it probably is not needed on the sc_req_item form. Then your g_form methods will work.



Let us know if you are still unsuccessful,


Gah! The community needs "presence" like ServiceNow does so I know you are typing at the same time.


Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi,



You need to add the field on the form in order to fetch the value at client script. However, once the field is added to the form, you can create a UI policy in order to show/hide the field.


thanks guys ! sorry pradeep he beat you by 1 minute... i thought this was the case... its a bit mucky really




I think ctomasi has an enhancement request / petition for enhancing the g_form which would be lovely