SATURDAY, MAY 19, 2012

GlideDialogWindow: QuickForms

A

couple of days ago I wrote about some cool ways that you can show system list information in GlideDialogWindow popups from a form. As promised, here’s another article showing some other ways that you can use GlideDialogWindow. If you want to see all of the articles I’ve written about GlideDialogWindow and popups in Service-now just use the tags at the bottom of this article.

In this article I’ll show you how you can use GlideDialogWindow to update records from a list with a multiple update or a form with an update or insert on a single record anywhere in the system.


Displaying a form popup from a form

Here’s an example I’ve used in the past that shows how you can use ‘GlideDialogWindow’ to show a popup from a form that you can use to update any record in the system (or make an insert into any table in the system). This example is a popup that shows required closure information when a UI action button is clicked.

1Create a new view on the table that has the form that you want to appear in the popup. For the new view you’ll just want to make sure that you include only the fields that are absolutely necessary to allow the user to make an update. In almost every case, your default form view will have way more information than is required. For this example I just added a few fields that would allow the user to enter resolution information about the incident.

2Create a UI action button that you can click to make the popup appear. Make sure to check the ‘Client’ checkbox and provide a value of ‘showMyForm()’ (or whatever the name of your ‘onclick’ function is) in the ‘OnClick’ field. For this example, I’ve added a condition of ‘!current.isNewRecord()’ so that the button doesn’t show up unless it appears on a valid record. Replace the reference to ‘ResolveDialog’ below with the name of your new view created in step 1 above.

‘Resolve Dialog’ UI Action
Name: Resolve Dialog
Table: Incident
Client: True
Form Button: True
OnClick: showMyForm()
Condition: !current.isNewRecord()
Script:

function showMyForm(){
   //Get the table name and sys_id of the record
   var tableName = g_form.getTableName();
   var sysID = g_form.getUniqueValue();

   //Create and open the dialog form
   var dialog = new GlideDialogForm('Update incident', tableName); //Provide dialog title and table name
   dialog.setSysID(sysID); //Pass in sys_id to edit existing record, -1 to create new record
   dialog.addParm('sysparm_view', 'ResolveDialog'); //Specify a form view
   dialog.addParm('sysparm_form_only', 'true'); //Add or remove related lists
   dialog.render(); //Open the dialog
}

Thanks to the forums I also found that if you need to pass values into the dialog from your original form, you can set a callback function to pass and set those values into your dialog like this…

function showMyForm(){
   //Get the table name and sys_id of the record
   var tableName = g_form.getTableName();
   var sysID = g_form.getUniqueValue();

   //Create and open the dialog form
   var dialog = new GlideDialogForm('Update incident', tableName); //Provide dialog title and table name
   dialog.setSysID(sysID); //Pass in sys_id to edit existing record, -1 to create new record
   dialog.addParm('sysparm_view', 'ResolveDialog'); //Specify a form view
   dialog.addParm('sysparm_form_only', 'true'); //Add or remove related lists

   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.g_form.setValue('close_notes', 'Hello world!');
   dialogFrame = null;
   });

   dialog.render(); //Open the dialog
}

3Since this form will include ALL of the buttons that normally display on the form, you’ll probably also want to add a client script that runs against the view you created and removes any unnecessary buttons. Typically you’ll just want to have the ‘Update’ button visible for something like this. An ‘onLoad’ client script that runs against your new view with a script like this should do the trick.

‘ResolveDialog remove buttons’ Client Script
Note that I’ve also added a couple of lines to set the value of the ‘Incident State’ field and make it read only. We don’t want people to modify the state from this popup form, but it needs to be set so that our UI Policy will display the closure fields and make them mandatory. Also note that I’ve used the ‘State’ field instead of ‘Incident State’ in my examples here. If you use ‘Incident State’ you’ll need to modify the script.

Name: ResolveDialog remove buttons
Table: Incident
Global: False
View: ResolveDialog
Type: onLoad

function onLoad() {
   //Set the incident state to Resolved
   g_form.setValue('state', 6);
   g_form.setReadonly('state', 'true');

   //Remove all buttons except for the 'Update' button
   var items = $$('BUTTON').each(function(item){
      if(item.id != 'sysverb_update'){
         item.hide();  
      }
   });
}

Here’s the end result. A simple, nice-looking form that allows you to make changes to any record in the system without navigating away from the record you’re currently viewing!

Displaying a form popup from a list (multiple updates with one action)

Here’s an example I’ve used in the past that shows how you can use ‘GlideDialogWindow’ along with the ‘showQuickForm’ method to show a popup from a list that you can use to update multiple records in a list with a single action.

The biggest drawback to this method is that it DOES NOT run client scripts or UI policies. Because of this, you’ll need to put a little more thought into exactly how you use it to present fields. It is also designed to ONLY work as a list action. The ‘showQuickForm’ method has also had some issues in the past (including a recent one with the ListV2 plugin). These issues have been resolved in the Fall 2010 Service-now release. If you’re seeing issues, chances are you need to upgrade.

1Create a new view on the table that has the form that you want to appear in the popup. For the new view you’ll just want to make sure that you include only the fields that are absolutely necessary to allow the user to make an update. In almost every case, your default form view will have way more information than is required. For this example I just added a few fields that would allow the user to enter assignment information about the incident.

2Create a UI action list choice menu option that you can click to make the popup appear. Replace the reference to ‘assignment’ in the condition below with the name of your new view created in step 1 above. You’ll also need to make sure that the ‘Action Name’ of your UI action matches the action name passed into your ‘OnClick’ function. Notice that I have ‘reassign’ for both the ‘Action Name’ and as a parameter going into the ‘showQuickForm’ function.

‘Reassign’ UI Action
Name: Reassign
Table: Incident
Action Name: reassign
Client: True
OnClick: showQuickForm(‘assignment’, ‘reassign’)
List Choice: True
Condition: gs.hasRole(‘itil’)
Script:

//Make sure State gets changed to 'Active'
current.state = 2;
current.update();

That’s it! There’s no need to remove extra buttons or form elements in this case. The ‘showQuickForm’ function takes care of that for you. You should be able to go to your record list, check a few records, and click the UI action choice option to see a popup that allows you to update multiple records with entries from your custom form in a single action.

Comments

Posted On
Sep 17, 2010
Posted By
Scott Brickell

Great information Mark!

Any thoughts on how to use this while ordering from the Service Catalog? In other words, you select a catalog item and when the screen loads, if any predetermined criteria is met, a user will be prompted for some unique information via a GlideDialogWindow.

Currently, I’m doing this with a JavaScript prompt which is not necessarily very elegant.

Many thanks,

Scott

Posted On
Sep 17, 2010
Posted By
Mark Stanger

This specific method won’t help you to do this because it has to use a predefined form and doesn’t return any information back to the client when it’s done. I’m planning on writing an article next week hopefully that shows how to use custom UI pages in a popup to perform certain tasks. I think you’ll be able to customize that solution to do what you want.

Posted On
Sep 23, 2010
Posted By
Mark Stanger

Just wrote a post describing a method that you should be able to use to accomplish what you want. Here’s the link.
http://www.servicenowguru.com/system-ui/glidedial

Posted On
Sep 22, 2010
Posted By
Samantha

Is there any way to pass values from the form containing the UI action into the dialog window? In my usecase the dialog window is not a view of the current form- its a view of another form so its not going to bring over existing values.

This part passes a sysID but I cant figure out how to pass other information off the original record.

dialog.setSysID(sysID);

I also posted this question on the community page.
http://community.service-now.com/forum/4587

Posted On
Sep 27, 2010
Posted By
Mark Stanger

I just discovered a solution that somebody figured out on the forums. I’ve documented it above but here’s the forum link as well.
http://community.service-now.com/forum/4587

Posted On
Oct 18, 2010
Posted By
computerdr74

Regarding multiple updates with one action…We have an ACL that prevents users from writing to the assignment group and assigned to fields if they aren’t a member of the current assignment group or if they aren’t the caller, etc. The issue is that we would like to allow an ITIL roled user to be able to multi-reassign or multi-resolve their tickets. They cannot do so with this ACL in place because the script references current which the quick form seems to have not context. Therefore, the ACL always returns false. (i.e. current.assigned_to == gs.getUserID();) How would one go about retaining the current security but also allow them to perform these multiple updates? I’ve tried everything I can think of without success.

Thanks for your help!

Posted On
Oct 18, 2010
Posted By
Mark Stanger

I’m glad you’re finding a good use for this. I think that your problem is that the security IS actually working. With the multiple update solution, the form that loads as ‘current’ is actually an empty multiple update form. So when you load the form you have an empty value for all of the fields. What you need to do in your ACL is make sure that people can write to the field if the field is empty. You can do that in script for the assigned_to field by adding a check like this…

answer = false;
 
//Can write if user is assigned_to
 
if(gs.getUserID() == current.assigned_to){
 
   answer = true;
 
}
 
//Can write if assigned_to is empty
 
if(current.assigned_to.nil()){
 
   answer = true;
 
}

This script will be evaluated when your multiple update form loads (allowing all users to provide input to the form) and will also be run when the update to each record occurs (allowing write access to only the appropriate records). Give this a try and let me know how it works. I just tested it on my demo instance and it seemed to work fine there.

Posted On
Oct 19, 2010
Posted By
computerdr74

Thanks for your quick reply. As you said, the security is working, which is great. My concern is that if I set it up the way that’s specified, which is one way I looked at it, users that we don’t want modifying these fields will be able to do just that. Putting it into context, we check the fields this way:

answer = false;
if (gs.getUser().isMemberOf(current.assignment_group)||
current.assigned_to == gs.getUserID() ||
current.opened_by == gs.getUserID() ||
current.caller_id == gs.getUserID() ||
gs.hasRole('u_incident_override') ){
   answer=true;
}
else{
   answer=false;
}

So, we don’t actually want the user to be able to modify the assigned_to or assignment_group fields unless one of the above conditions is met. Problem is that if we allow them to modify any incident that has an empty assigned to or assignment group, then that is considered a defect.

Is there a way to bypass an ACL, possibly in the ACL itself or by creating a new ACL that will handle an empty multiple update form?

Thanks for your input on this, it is greatly appreciated!

Posted On
Oct 19, 2010
Posted By
Mark Stanger

The only other thing I can think of right now would be to go ahead and open your security up a bit to allow for them to write to the field but add a business rule check to abort the record submission if the tightened security requirements weren’t met…specifically if the value changed from NULL to something else. This way they could still write to the multiple update form, but the update to each record would be evaluated individually for those records that started out with NULL values. Here’s another article I wrote describing how you could implement a server-side abort in a business rule.
http://www.servicenowguru.com/scripting/stopping-

Posted On
Oct 19, 2010
Posted By
computerdr74

Yep, got it. Thought about this, too. I will run this past them to make sure this is feasible. I know when I first asked them about this they were hesitant to allow the fields to be editable in the first place. They were concerned that it was deceiving. Let me check into this and see if they would be satisfied with this approach.

Thanks!

Posted On
Nov 29, 2010
Posted By
Amy

Hi Mark, I am trying to use GlideDialogForm to create a new record on click on UI action. The pop up opens and the record also gets created. However, if the user wants to close the pop up without submitting the form pop up, the close (x) icon gets hidden in internet explorer. It works fine in Mozilla. I thought of creating a Cancel button to close the pop up, but could not find how to use destroy() function on GlideDialogForm. Any clue on how to make pop up header visible in IE?

Posted On
Nov 29, 2010
Posted By
Mark Stanger

Hey Amy,

This really sounds like a bug of some sort. The first thing I would do is test the exact same setup at https://demo.service-now.com and see if the problem still exists there. If it does then you’ll want to contact support about the bug. If it doesn’t, then you’ll want to contact support about an upgrade.

The default GlideDialogForm is pretty locked down so I’m not sure there’s much you can do. You might be able to set up an onLoad script for that specific form view and override the function that gets executed when the submit button gets clicked. You might also be able to set up your own custom dialog window as shown here.

http://www.servicenowguru.com/system-ui/glidedial

Posted On
Nov 30, 2010
Posted By
Amy

Thanks Mark!

I could resolve the IE problem by using

dialog.setLoadCallback(function() {
 
dialog.moveTo('20', '40');
 
});

Now, when I submit the form, the parent form gets refreshed which I do not want. I observe that there is sysparm_refresh parameter which gets set as sysparm_refresh=refresh. Is there any way I can stop refreshing the parent form? Also, is there any function like removeParm or deleteParm like addParm?

Posted On
Nov 30, 2010
Posted By
Mark Stanger

There’s no ‘remove parameter’ function that I know of. I still think this is a bug that you should report to support since it works in Firefox.

Posted On
Dec 09, 2010
Posted By
Tony Nelson

Mark,

I’m trying to use your code to pop a dialog form to allow level one to enter a user record. I’m getting a pop-up to appear that has the title on it but the form has not fields present and down not expand past the title bar. Below is the code I’m using…I believe the issue I’m experiencing is because I’m changing tables from the incident table to the sys_user table. I thank you in advance for any assistance you could provide.

function showMyForm(){
 
   //Get the table name and sys_id of the record
 
   var tableName = g_form.getTableName();
 
   var sysID = g_form.getUniqueValue();
 

 
   //Create and open the dialog form
 
   var dialog = new GlideDialogForm('Add a Contact',tableName); //Provide dialog title and table name
 
   dialog.setSysID(sysID); //Pass in sys_id to edit existing record, -1 to create new record
 
   dialog.addParm('sysparm_view', 'adding_a_contact'); //Specify a form view
 
   dialog.addParm('sysparm_form_only', 'true'); //Add or remove related lists
 
   dialog.render(); //Open the dialog
 
}
Posted On
Dec 09, 2010
Posted By
Mark Stanger

If you’re triggering this from an incident record and the popup should show a form for a user record then you need to change the ‘tableName’ and ‘sysID’ values. The ‘tableName’ value should point to ‘sys_user’ and ‘sysID’ should be ‘-1′. Just change the first 2 variable lines in the script to these values and it should work better.

Posted On
Dec 31, 2010
Posted By
Peter Oneppo

Mark,

I’ve made it so that while a user is entering an Incident, they can bring up the caller’s record to update it. Everything works great except that when the user clicks the ‘Update’ button on the popup, the incident is reloaded and any unsaved information is lost. How can I make it so that the ‘Update’ button for the User form has no affect on the Incident form?

Thanks,

Peter

Posted On
Jan 04, 2011
Posted By
Mark Stanger

Hey Peter,

I’m not sure of a way to do that with a quickform. You’re probably better off in this case to pop open a new window for the record insert/modification you need. You can call ‘popupOpenStandard(url)’ from any client script and open up a new window that will allow a save without impacting the base form. You just need to construct the URL and pass it in.

Posted On
Dec 10, 2010
Posted By
Tony Nelson

Mark…you rock! That worked perfectly. Thanks for the help.

Posted On
Jan 17, 2011
Posted By
Nikita

Hi Mark

I removed the buttons from glidedialog pop-up but have troubles removing UI Actions known as Links (Related Links). They are displayed in GlideDialog window and I want to get rid of them there. Can you please give me a hint? I was thinking about checking the view name in UI Action Condition but could not find any method that can do that.

Posted On
Jan 18, 2011
Posted By
Nikita

This is a piece of client script that helped me removing Related Links UI Actions from GlideDialog pop-up:

var refs1 = document.getElementsByClassName('related_links_container');
 
//Remove Realted Links UI Actions from the form
 
if (refs1) {
 
   for (i=0; i < refs1.length; i++) {
 
      var ref1 = refs1[i];
 
      inner = ref1.innerHTML;
 
      if (inner){
 
         ref1.style.display = 'none';
 
      }
 
   }
 
}
Posted On
Jan 19, 2011
Posted By
VincentB

Hi Mark,

First, thanks for this article.

I have a question concerning the fields presents in the ‘ResolveDialog’ view. Indeed, in the article you only use out of box fields and the size of the popup is automatically adapted to the view form.

Nevertheless, I’m trying to use manually created fields in my view (u_solution for example). When adding it to the view, the size of my popup is not adapted and i have to use scrollbar to see all my fields…

Do you have any ideas on how to solve this problem? (change the size of the form?, Change a property in my fields?, …)

Thanks in advance,

Vincent

Posted On
Jan 19, 2011
Posted By
Mark Stanger

You should be able to use ‘setSize(width,height)’ to resize your dialog to accommodate the larger form if necessary. Check out this post for an example.
http://www.servicenowguru.com/system-ui/glidedial

Posted On
Jan 19, 2011
Posted By
VincentB

Thanks for your quick answer Mark!

I already had a look to the post you just linked to me, and tried to use the setSize property on my GlideDialogForm object. Nervetheless this property seems not working correctly if it is not on a glidedialogWindow. Indeed only the width of the popup changes, and even if the popup is larger, the scrollbar to move from left to right is still present because only the container’s width has increased and not the form.

Posted On
Jan 19, 2011
Posted By
VincentB

Mark, I just find out why i had the problem. It came from an error in UI Policy. After a quick look, the setSize property is not necessary with the GlideDialogForm object and the window is automatically adapted.

Thanks again and good evening !

Vincent B

Posted On
Feb 24, 2011
Posted By
JimC

I’m using this functionality to replace the “Add New Item” pop-up dialog on the Request form. I created a new view on the sc_req_item table and the dialog displays nicely for admin and itil users. However, I need ess users to be able to use the new form as well. The dialog appears, but uses the ess view instead of the new view. They are allowed to add items until they actually submit the request for approval (we’ve added a default Draft state to the request).

Any reason why the new view is not displayed for the ess users?

Thanks

Jim

Posted On
Feb 24, 2011
Posted By
Mark Stanger

Yep. The system forces the ess view for the request and request item tables. This can be overridden if necessary. See this post for details. http://www.servicenowguru.com/system-ui/ui-pages-

Posted On
Feb 24, 2011
Posted By
JimC

I did use that post to override the sc_request table, but missed the sc_req_item section – thanks. Now I’m going to try to force the new view only for the popup and the ess view for the others.

Posted On
Feb 28, 2011
Posted By
Brian Broadhurst

Hi Mark,

I’m using this technique to capture Incident resolution details, as in your example. What we are finding is that when the pop-up is submitted (via the Update button), the parent form is redisplayed (not an issue), but in order to go back to the previous list view, we have to click the green back arrow twice – the first click redisplays the Incident form again. Same thing happens if after the popup, we click Update on the parent form – the parent form gets displayed again, then clicking Update a second time takes us back to the list view. Seems to me that the navigation stack is ending up with one more entry than we need. Any ideas how we can get around this?

Brian Broadhurst

Posted On
Feb 28, 2011
Posted By
Mark Stanger

The only thing I can think of is to try setting the ‘sysparm_stack’ parameter when you render your dialog window or set up a UI action/Business rule redirect to handle this specific case.
http://wiki.service-now.com/index.php?title=Navig

Posted On
Mar 30, 2011
Posted By
JimC

I mentioned above that I’m using the popup to replace the “Add New Item” pop-up dialog on the Request form. I created a new view on the sc_req_item table and it is working nicely. However, the Short description field is showing up as Read-only for ESS users, BUT the field is writeable if you click on the item link in the related list below. I had to override the Access Control rules to allow it to be writeable, but it seems like it is not quite making it into the popup window for some reason but is fine in the “normal” form.

Posted On
Mar 30, 2011
Posted By
Mark Stanger

That is strange. Check your ACLs on ‘sc_req_item’ and ‘task’ for anything view-related. The only other thing I can think of that would do that is a UI policy or client script. If you can set up a test case and reproduce it on demo I’ll take a look.

Posted On
Mar 30, 2011
Posted By
JimC

It’s definitely ACL based. I added some more ACLs to lock down the fields depending on the state of the Request and now all the fields are Read-only in the popup but editable in the real form. The field is editable if I deactivate the appropriate ACL.

I’ll see if I can set something up in demo.

Posted On
Mar 30, 2011
Posted By
JimC

I’ve added a “Test popup” UI Action to the Request table in Demo. I’m playing with it to see if I can duplicate the issue I’m seeing.

Posted On
Mar 31, 2011
Posted By
JimC

For those who are interested, the problem was with the drill-through to the request record. This works fine if the item has already been created, but results in an invalid reference for a new item record since the item really did not exist. I modified the condition script in the ACLs and it now works perfectly:

var answer = false;
 
if(current.request.request_state == 'draft' &amp;&amp; (current.request.u_request_type == 'x' || current.request.u_request_type == 'y')){
 
   if(current.request.opened_by == gs.getUserID() || current.request.requested_for == gs.getUserID() || gs.hasRole('itil')){
 
      answer = true;
 
   }
 
}
 
if(current.isNewRecord()){
 
   answer = true;
 
}
 
answer;

The check for the new record enables the fields in the popup window to be editable.

Thanks for the help Mark.

Jim

Posted On
Apr 01, 2011
Posted By
Blair

How can I change name of the button on the pop window from the list view?

Posted On
Apr 01, 2011
Posted By
Mark Stanger

I’m not sure I follow. Is this a GlideDialogWindow question?

Posted On
Apr 01, 2011
Posted By
Blair

Yes, sorry I was a vague in my last post. I used the GlideDialogWindow Client script on a UI Action within a list. Instead of the word “Update” on the button, we want the word “Submit”. I see it’s defined under “sysverb_post_update”, but I don’t know where to change that.

Posted On
Apr 01, 2011
Posted By
Mark Stanger

The list popups aren’t really customizable. They don’t support client scripts on the forms they present so there’s not a way I know of to change the button text for that popup.

Posted On
Apr 04, 2011
Posted By
Blair

Mark,

Thanks for your help.

Posted On
Apr 25, 2011
Posted By
Chris York

Mark, This worked great for me. In your example where you are using this to record Close Notes for an Incident, It would be nice to return back to the list of records instead of back on the Incident that you just updated with the GlideDialogForm. Is there a way to redirect to the list instead? Similar to just clicking update on the main form.

Posted On
Apr 25, 2011
Posted By
Mark Stanger

You can set a completion callback right before the ‘dialog.render()’ line like this to do the redirect…

dialog.setCompletionCallback(function() {
 
   window.location='incident_list.do';
 
});
Posted On
Apr 27, 2011
Posted By
Jason Thomas

Hi Mark

Instead of using the client script to remove the buttons, you can use the UI Action Visibility, to exclude the buttons from that view.

Just a thought.

Posted On
Apr 28, 2011
Posted By
Mark Stanger

Thanks Jason,

You’re exactly right. I wrote on the topic of form button removal before here…
http://www.servicenowguru.com/scripting/client-sc

UI action visibility is a great way to remove form buttons for specific views and it should definitely be strongly considered any time you remove form buttons. For this case where there may be 1 or 10 buttons to remove I kind of like to do it all in one spot with the client script but either way works great.

Posted On
May 30, 2011
Posted By
Divya

Hi Mark,

I am using this code to create a pop up from a UI action(list choice). Here i am trying to use modify UI action and it opens up a pop up with few fields which i want to modify. But the problem i face is when i fill in those fields and click on submit a new incident record is getting created and the values are not getting updated to my required record Could you please help me out with this?

This is the code i used

var sysID = current.sys_id;  
 
function showMyForm(){  
 
//Get the table name and sys_id of the record    
 

 
   //Create and open the dialog form
 
   var dialog = new GlideDialogForm('Modify incident', 'incident'); //Provide dialog title and table name
 
   // dialog.setSysID(sysID); //Pass in sys_id to edit existing record, -1 to create new record
 
   dialog.addParm('sysparm_view', 'modify2'); //Specify a form view
 
   dialog.addParm('sysparm_form_only', 'true'); //Add or remove related lists
 
   dialog.render(); //Open the dialog
 
}
Posted On
May 30, 2011
Posted By
Mark Stanger

The problem is that you’re using code that is designed to be initiated from a form, not a list action. With a list action, you need to use the list code in this article.

Posted On
Jun 24, 2011
Posted By
Michele King

I am using the GlideDialogForm to update the Priority and require notes on why the priority was changed. I want a Cancel button on the form so I can “cancel” the change instead of using the “X” in the top right corner. Any suggestions on how to destroy the form?

Thanks-Michele

Posted On
Jun 24, 2011
Posted By
Mark Stanger

You’ll need to test this but you should be able to create a UI action just for that popup view to show a ‘Cancel’ button. The UI action would need to run a client-side function and leverage the ‘destroy’ method to close the dialog like this…

GlideDialogWindow.get().destroy(); //Close the dialog window
Posted On
Jul 22, 2011
Posted By
Michele King

Got it. Actually I just have a cancel button (action = cancel) not client callable and just has the script

action.setRedirectURL(current);

and in the original UI Action which calls the dialog window, I added

if (action == 'cancel') {
dialog.destroy();
}

and that works perfectly.

Posted On
Jul 21, 2011
Posted By
Joe

When using showQuickForm() in a UI Action you must make it a client side script for the pop up, but the script is written like a business rule (for example, all I have in my script is current.update()). In my instance I’m seeing a javascript error on the list view “current not defined”, but if I don’t use current.update() the records don’t get updated. Any ideas on how to get around this so that the UI Action works and I don’t get any nasty errors?

Posted On
Aug 23, 2011
Posted By
Vincent B

Hi Mark,

I’m experiencing some issues since the high security plugin has been activated (before everything worked perfectly). Did you already tried this script on an instance with the High Secu Plugin?

Thanks in advance,
VincentB

Posted On
Aug 23, 2011
Posted By
Mark Stanger

I haven’t ever heard of any issues with the dialog related to the high security plugin. I just copied this example into my own personal instance (which has the high security plugin enabled) and I didn’t have any issues. The only thing I can recommend is to try to recreate the example given here exactly and see if that works and go from there.

Posted On
Sep 14, 2011
Posted By
Daniel

Hi Mark,
thanks for this awesome tip! Finally I was able to create a AJAX Popup within the Assign-To-Me function to enable the verification of the assignment group by the user.
Best regards,
Daniel

Posted On
Oct 20, 2011
Posted By
Swaminathan

Do we have some way to hide close(X) button for the user,We need it in a scenario when we place some mandatory field in the quick form and we don’t want the user to escape the mandatory check by pressing the close button.

Posted On
Oct 20, 2011
Posted By
Mark Stanger

I’m not sure if this will work with a quick form or not, but you could try adding the following when you set up your dialog…

dialog.removeCloseDecoration(); //Remove the dialog close icon

You can see how this works for a regular dialog here…
http://www.servicenowguru.com/system-ui/glidedialogwindow-terms-conditions-acceptance-page/

Posted On
Nov 28, 2011
Posted By
Pratik

Hi Mark

Can we have a Glide List embedded in a UI Page?
If not what are the options we have for multi pick list on a UI Page?

Thanks,
Pratik

Posted On
Nov 28, 2011
Posted By
Mark Stanger

You can, but it can be difficult to get them to work just the way you want. There are UI macros in the system for both glide list (lightweight_glide_list) and slushbucket (ui_slushbucket). You can search the UI pages in the system for references to these macros to see how they are used.

Posted On
Jan 18, 2012
Posted By
Jason

Hi Mark

I’d like to have the window popup and then either use a submit button, which submits the record and closes the popup window (returning the user back to the initial record), or use an add another button which adds another record, but remains within the popup window.

any ideas on how to achieve?

Posted On
Jan 18, 2012
Posted By
Mark Stanger

I don’t have an exact solution for you, but I think what you’re going after will be somewhat similar to the solution I’ve documented here.
http://www.servicenowguru.com/system-ui/ui-macros/adding-referenced-records-leaving-form/

Posted On
Jan 20, 2012
Posted By
Jason

I have the popup etc working, the only part not working is the add additional button.

The user needs to add multiple expenses via the sys_popup dialog.
The user can currently submit a single expense record.

I am using the same code as the insert and stay button, which I assume is where the problem lies, because its doing a submit, and thus calling the callback function.

Is there a way to perform the insert but not return back to the record until either the submit button is clicked (already working) or the close button.

Thanks

Posted On
Jan 20, 2012
Posted By
Mark Stanger

I’m not aware of a simple solution to that but you may ask on the forums.

Posted On
Jan 19, 2012
Posted By
Bryan Barnard

Is there a way to hide a reference icon on a form in this case the view I’m using in my QuickForm. My Quickform is quite small and only has one field ( a reference field) and the problem is that when a value is selected for the reference then the Reference Icon shows up. If the user hovers on that then due to the small size of my form it will become rather crowded. I would rather just eliminate the reference icon.

I’ve tried client script via ‘Client Scripts’ and ‘UI Policies’ but it seems that the SN Script that runs to add the Reference Icon always runs after my client script so even if change the display to ‘none’ in mine the later running script changes it back to display.

Thanks,
Bryan

Posted On
Jan 19, 2012
Posted By
Mark Stanger

The only way to do this is to remove the element completely because the field change logic for a reference field is designed to show the field every time you populate a valid value. Here’s a snipped you could use in a client script.

Make sure to run the script ONLY for the popup view. You should just have to replace ‘incident.caller_id’ with the table and field name you’re using.

$('view.incident.caller_id').hide();
Posted On
Jan 20, 2012
Posted By
Bryan

Thanks!

I tried using hide() but still had issues, switched to .remove() and it worked perfectly.

$(‘view.incident.caller_id’).remove();

Posted On
Jan 20, 2012
Posted By
Mark Stanger

Ugh. I hope that didn’t cost you too much time. remove() is what I meant to paste in to give to you. I’m glad you’ve got it working.

Posted On
Jan 20, 2012
Posted By
Bryan

only a couple mins. I had to read your comment twice because I read remove and then saw the example “hide()”, and thought i’m pretty sure he meant remove but I’ll tried hide just in case..

thanks again

Posted On
Feb 01, 2012
Posted By
Jason

Hi Marc

Just thought I’d share an issue I was having, and the solution….

I had created a UI macro which had a button element in it, that when clicked called the GlideDialogWindow.
It worked perfectly in IE but was inserting empty records in firefox.

It turns out that the button element in firefox was performing a submit action (default action in firefox, not in IE) and thus submitting the form.
To fix, you need to add the type=”button” attribute to the button element.

Cheers
Jason

Posted On
Feb 01, 2012
Posted By
Mark Stanger

Great tip! I’ve had that same issue with buttons WITHIN dialogs as well. Took me longer than I wanted to figure it out :) .

Posted On
Mar 27, 2012
Posted By
Amir Karami

Hi Mark,
Is there any way to make the fields required required on popup form when using the “showQuickForm’ method?

Posted On
Mar 27, 2012
Posted By
Mark Stanger

The list-based quickform can’t do mandatory fields. The form-based quickform just uses the client scripts and UI policies for that form view.

Leave a Reply


Notify me of followup comments via e-mail. You can also subscribe without commenting.

Latest Comments

  • Jim Coyne: I’m not sure exactly what you are looking for, but can you use “window.location” in your...
  • Ian: Might want to check the single quotes around ITIL in the condition line, they gave an error for me until I...
  • Mark Stanger: That’s correct. This returns instance URLs. I don’t have an equivalent currently that...
  • ND: Hi Mark, This is very useful information. I am looking for similar method to find URL of a site created by us. We...