g_form.geFieldNames() not working

chitra11
Tera Contributor

I am using catalog client script on submit as below

    var allFields = g_form.getFieldNames();

        for(var fieldName in allFields){

                alert( allFields[fieldName]);

        }

it is not working and not allowing to submit the form. 

is  g_form.getFieldNames() is deprecated? If yes any other way to get all variables shown on the form to get populated in client script ?

We like to send notification with variables only variables shown on the form even user didnt provide info in those variables. hidden variables through UI script shouldnt be sent. 

19 REPLIES 19

Yes I agree if its hidden its not ahve value. but even varaibles on the form is not filled by users but we need that in the notification as it is shown to the users and it is intentionally not filled by user.

just confirming, you are saying you want to send empty variables to target user to notify these variables value has not filled ? if this is the scenario then reverse the if block condition in the above script 

 

check for =='' instead of !=''

Sorry, just to clarify we want variable need to be sent to users if it is shown on the form even it is filled or not filled.

It should not send any variables which are not shown to users including UI policy hidden variables.

Ideally  it should replicate what user saw while submitting service request. 

OOTB , i don't think any glide form API method will give you these details. 

 

adding one thread here, kindly have a look. see if it helps you. 

 

https://community.servicenow.com/community?id=community_question&sys_id=5e9d0f2ddb9cdbc01dcaf3231f96...

How to iterate all variables in the catalog item? isvisible will work if we pass variable name. but can you please tell how to iterate through all variables on the form?