Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

GlideDialogForm set view not working for users but works for admin

Chandler B
Mega Contributor

I have a GlideDialogForm popup for the customer_contact form that I want to display in a certain view. When I run it as an admin, it opens correctly in the view I set regardless of what view I have last viewed the form in. When I run it as a user it opens in the last view (possibly their preference view) they viewed the customer_contact form in. They do have access to set their view to the one I want to open as if they are on the form. To set the view, I run this before rendering it:

dialog.addParm('sysparm_view', 'Requestor2');

 

Why is this only working as an admin?

1 ACCEPTED SOLUTION

Weird that should have forced the view do you have avy view rules can uou check once?

View solution in original post

7 REPLIES 7

Saurav11
Kilo Patron
Kilo Patron

Hello,

Can you paste some screenshots then it would be easier to assist you.

Thanks.

Sure, I have a UI action called 'Create Contact'. When I click that, this GlideDialogForm opens up and it opens in the 'Requestor2' view as it should. 

find_real_file.png

 

Now when I do the exact same thing while impersonating a user that is not an admin, it opens the customer_contact form in the last view that they used on the page. 'case' view in this example. 

 

find_real_file.png

 

Hello,

Can you use the below:-

d.addParm("sysparm_view", "Requestor2");

d.addParm("sysparm_view_forced", true);

 

Please mark answer correct/helpful based on Impact

Unfortunately that didn't work. Still opens as the 'case' view for users without admin. Any other ideas? Here is what I have for the popup right now:

 

var dialog = new GlideDialogForm('Create Contact', 'customer_contact', contactCallback);
dialog.setTitle('Create Contact');
dialog.addParm('sysparm_view', 'Requestor2');
dialog.addParm('sysparm_form_only', 'true');
dialog.addParm('sysparm_view_forced', 'true');
dialog.setLoadCallback(function(iframeDoc) {
// To get the iframe: document.defaultView in non-IE, document.parentWindow in IE
var dialogFrame = 'defaultView' in iframeDoc ? iframeDoc.defaultView : iframeDoc.parentWindow;
dialogFrame.addLoadEvent(function() {
dialogFrame.g_form.setValue('first_name', fname);
dialogFrame.g_form.setValue('last_name', lname);
dialogFrame.g_form.setValue('email', g_form.getValue('u_email'));
dialogFrame.g_form.setValue('phone', g_form.getValue('u_phone'));
dialogFrame.g_form.setValue('user_name', g_form.getValue('u_email'));
dialogFrame.g_form.setValue('account', g_form.getValue('u_account'));
});
});
dialog.render();

 

 

 

(Also, for testing purposes I commented out the setLoadCallback and it still doesn't work)