Need to populate date field as mandatory in service operations workspace pop up view

Prabhavathy3
Tera Contributor

Hi,
Can someone please help me to understand how we can use date field to be shown in pop up once some button is clicked in Service operations workspace view. What will be the type for date in workspace client script in UI action?
Below is the script which I have written but not working.
var fields = [{
type: 'Date',
name: 'date',
label: getMessage('Duration'),
mandatory: true
},
g_modal.showFields({
title: "Reason",
fields: fields,
size: 'lg'
}).then(function(fieldValues) {
g_form.setValue('date', fieldValues.updatedFields[0].value);
g_form.save();
});
}

Thanks,
Prabhavathy

2 REPLIES 2

S Goutham
Tera Guru

Hey @Prabhavathy3 :

 The g_modal doesn't seem to support date picker yet, Below is the link to the existing blog on this issue been faced by many users

https://www.servicenow.com/community/developer-forum/g-modal-field-type-for-date-field/m-p/1864612

 

For now, we can have it have a string input and train the user to enter the date or if we have an existing UI page then we can call the UI page in the g_modal to show that shows up in an iframe

 

https://www.servicenow.com/community/next-experience-articles/how-to-use-ui-actions-in-workspaces/ta...

 

Use the example of the showFrame method mentioned in the article to bring up the UI page.

 

 

 

I hope this solves your issue
Mark this as Helpful / Accept the Solution if this clears your issue

Thanks @S Goutham 
Yes you were right there is no such option to add date picker in g_modal. But is it possible to add other reference field based on choice field selected in service workspace.
For example:
if choice field have 3 choice values and if value 1 is selected then based on that some reference field should be made mandatory and available in pop up and should be hidden if other choice value selected to show other mandatory field.

Thanks in advance.
Prabhavathy