Can I destroy and then create a pop-up via snippet?

  • 2
  • Question
  • Updated 4 years ago
  • Answered
  • (Edited)
I have a pop-up that creates a case.  When I save the case record I'd like to give the user the option to create a related task.  If they opt-in to creating a task after creating the case I like the case pop-up to go away and then a new pop-up to appear with a task creation page.

Can someone drop me the javascript code to render a new pop-up?

Thanks!
Photo of Peter Herzog

Peter Herzog

  • 1,664 Points 1k badge 2x thumb
  • skuidily

Posted 4 years ago

  • 2
Photo of Moshe Karmel

Moshe Karmel, Champion

  • 8,646 Points 5k badge 2x thumb
Destroying a snippet is pretty easy with this line:

skuid.$('.ui-dialog-content').dialog('close');

Creating one is a lot more complex. Here is an example of a popup created using JS. You basically have to spell out the XML...

var params = arguments[0],   $ = skuid.$,
   list = params.list,
   model = params.model,
   $xml = skuid.utils.makeXMLDoc;

var popupXMLString = 

    '<popup width="50%" title="Error">'
        + '<components>'
            + '<pagetitle model="Opportunity">'
                + '<maintitle>' + 'An error occurred.' + '</maintitle>'
                + '<actions>'
                    //+ '<action type="custom" snippet="FinishCaseEscalation" label="Complete Escalation" icon="ui-silk-accept"/>'
                + '</actions>'
            +'</pagetitle>'
            + '<basicfieldeditor model="Opportunity" mode="edit" showsavecancel="false">'
                + '<columns>'
                    + '<column width="100%">'
                        + '<sections>'
                            + '<section title="Escalation Reason">'
                                + '<fields>'
                                    + '<field id="CommentBody" required="true"/>'
                                + '</fields>'
                            + '</section>'
                        + '</sections>'
                    + '</column>'
                + '</columns>'
            + '</basicfieldeditor>'
        + '</components>'
    + '</popup>';

var popupXML = $xml(popupXMLString);

var context = {};

var popup = skuid.utils.createPopupFromPopupXML(popupXML, context);
Photo of Peter Herzog

Peter Herzog

  • 1,664 Points 1k badge 2x thumb
This looks good!  Thanks Moshe!
Photo of Sasidharreddy myf

Sasidharreddy myf

  • 152 Points 100 badge 2x thumb
Thanks Moshe!

can i call one more snippet through this...

      //+ '<action type="custom" snippet="FinishCaseEscalation" label="Complete Escalation" icon="ui-silk-accept"/>' 
Photo of Moshe Karmel

Moshe Karmel, Champion

  • 8,646 Points 5k badge 2x thumb
It looks like that line has a snippet call inside it " snippet="FinishCaseEscalation" ". If you have a snippet with that name that would probably work. Or you might have to declare the snippet in the XML like:

<javascript>         <jsitem location="inlinesnippet" name="ContractRequest" cachelocation="false" url="">var $ = skuid.$; ETC...