ServiceNow UIB Client Script to emit mandatory field

SiddhardhaN
Tera Guru

I am working on creating a page for new record creation with 2 buttons - Draft and Submit. When user clicks on Draft button - I would like to flip all mandatory fields to false before saving the record. I was successful configuring the button click event handler using 'set Mandatory' event using below script. However, I have 10 fields to do so. I would like to have client script triggered for all these fields instead of setting up one event handler for each field. 

 

 

 

/**
* @Param {params} params
* @Param {api} params.api
* @Param {any} params.event
*/
function evaluateEvent({api, event}) {
	return {
		fieldName: "short_description",
		mandatory: false
	};
}

I see examples online using api.emit() for adding notifications on form page; any pointers what is the equivalent event name for setting mandatory field thru client script?

 

api.emit('NOW_UXF_PAGE#ADD_NOTIFICATIONS', {
        items: [{
            id: 'alert1',
            status: 'positive',
            icon: 'check-circle-outline',
            content: 'Here is some information!',
            textLinkProps: {
                label: 'More info',
                href: 'https://www.servicenow.com'
            },
            action: {
                type: 'acknowledge'
            }
        }]
    });

 

 

0 REPLIES 0