Interested in a ServiceNow event built for developers? Registration for now[dev]26 is officially open!

I have created a declarative action for fso workspace for a custom table i want to show popup modal

Debasis Pati
Kilo Sage

I have created a declarative action for fso workspace for a custom table i want to show popup modal when the declarative action is clicked.
I am very new to ui builder can anyone let me know how i can do this?

Regards,
Debasis

3 REPLIES 3

Ankur Bawiskar
Tera Patron

@Debasis Pati 

you can check many OOTB Declarative actions which work in workspace and show pop up modal

it's rendered using g_modal

check this

How to use UI Actions in Workspaces 

💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 10x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hello @Ankur Bawiskar ,

I tried the below script
function onClick(g_form) {
g_modal.showFields({
title: "Enter your reason",
fields: [{
type: 'choice',
name: 'type_of_document',
label: getMessage('Type of Document'),
value: '',
mandatory: true,
choices: [{
displayValue: '-- Select --',
value: ''
}, {
displayValue: 'PDF',
value: 'pdf'
}, {
displayValue: 'Document',
value: 'document'
}]
}, {
type: 'textarea',
name: 'work_notes',
label: getMessage('Reason'),
mandatory: true
}],
size: 'lg'
}).then(function(fieldValues) {
// fieldValues.updatedFields[0] -> type_of_document
// fieldValues.updatedFields[1] -> work_notes
g_form.setValue('u_type_of_document', fieldValues.updatedFields[0].value);
g_form.setValue('work_notes', fieldValues.updatedFields[1].value);
g_form.save();
});
}
It is showing the modal but when i select a value and click on ok it is not setting the field value the save of the form is not happening.I have already added the field on the form and the view but it is not setting the value the alert is giving the value correctly but form is not getiing save d neither the u_type_document value is getting set on form as well just the modal choice box comes with values if i selct and save nothing happens.

Dinesh Chilaka
Mega Sage

Hi @Debasis Pati ,

Follow the below article to use declarative actions with ui builder
Declarative Actions with UI Builder 

Let me know if you found any issues .If my response helped, mark it as helpful and accept the solution.

 

Thanks,

Dinesh