Run script snippet before popup

  • 2
  • Idea
  • Updated 4 years ago
  • Implemented
Archived and Closed

This conversation is no longer open for comments or replies and is no longer visible to community members. The community moderator provided the following reason for archiving: Outdated post with relevant discussions. Forked two discussions.

It would be great if there was an easy way to run a script snippet before a popup opens. The snippet could be used to set constraints on models and refresh model data to display in the poup.

With this feature you would not have to hand code poup content if you wanted the model to depend on the clicked row.

An example: If you have a related list of opportunities on the account page you could create a row action popup with all the notes belonging to that opportunity.
Photo of William Sporrong

William Sporrong

  • 396 Points 250 badge 2x thumb

Posted 6 years ago

  • 2
Photo of Zach McElrath

Zach McElrath, Employee

  • 53,784 Points 50k badge 2x thumb
Hi William,

We are considering adding a few more Row Action types, one of which is "Run snippet then show popup".

However, you actually don't have to "hand code popup content" in order for data within the popup to depend on the clicked row. In the Skuid Summer 13 Deep Dive video, we explore an example synonymous to yours in which, on an account page, we have a table of Cases related to that Account, and then we create a row action on the Cases table that launches a popup, which lets you edit Case Comments related to the Case row in context.

For the best explanation of how this works, check out the Skuid Deep Dive video, starting at 5:30 and going through about 11:30



(To start right at 5:30, click here: Skuid Summer 13 Deep Dive, starting at 5:30)
Photo of William Sporrong

William Sporrong

  • 396 Points 250 badge 2x thumb
Great stuff. I did not realize that. This means that one of the tutorials here (showing full comments on a task list) is obsolete.
Photo of William Sporrong

William Sporrong

  • 396 Points 250 badge 2x thumb
There seems to be an issue with the popup "smartness". I want to display to models with the same sObjects (example: Account, Related Accounts). But the popup seem to limit both models to only include the id of the row clicked. I.e related accounts will always be empty.....
Photo of Zach McElrath

Zach McElrath, Employee

  • 53,702 Points 50k badge 2x thumb
Hi William, looks like you're right. However, there is a workaround here. If you go into the page XML, you can change the Conditions governing what data gets into your popup table for Child Accounts. If you click "View Page XML" for your page, you should be able to do a search for "popup" and find your Row Action popup's XML. If you look inside it, you'll find the XML for your Child Accounts table, which should have a child <condition> node, which looks like this:


<condition type="contextrow" field="Id" autocreated="true"/>


These "autocreated" conditions are the "smartness" that Skuid automatically puts in while you're building popups.

If you change the field="Id" to be field="ParentId", then, as long as your accounts model has the ParentId field in it, your Child Accounts table in the popup should be filtered to just Child Accounts of the Account row in context.
Photo of William Sporrong

William Sporrong

  • 396 Points 250 badge 2x thumb
Thanks but I can't get this to work. Does the contextrow always take the primary key of the row to create the condition? I.e. in your example parentId = row.Id? In my case I want to use another field. Example: Show all other accounts from the same state.
Photo of Zach McElrath

Zach McElrath, Employee

  • 53,702 Points 50k badge 2x thumb
you can specify the "primary key" field / merge field to dump in with the "mergefield" attribute, e.g.



<condition type="contextrow" mergefield="MailingState" field="BillingState" operator="="/>

Photo of William Sporrong

William Sporrong

  • 396 Points 250 badge 2x thumb
Excellent! thanks
Photo of Peter Kong

Peter Kong, Employee

  • 596 Points 500 badge 2x thumb
Archiving this post; this discussion will prove useful in the future!

Please reference the new conversation here: Setting Popup Row Context
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,828 Points 20k badge 2x thumb
You are fight William. The Javascript described to open a popup with full conversation details is no longer necessary. Standard skuid can do that. Thanks for pointing that out. We will fix the tut...
Photo of Menachem Shanowitz

Menachem Shanowitz

  • 1,094 Points 1k badge 2x thumb
Can this be done with a mass action popup?
Photo of Zach McElrath

Zach McElrath, Employee

  • 53,784 Points 50k badge 2x thumb
As of the Summer 14 release of Skuid, you can use the Action Framework to run a snippet and then show a popup. When creating a Mass Action, set the type of "Run multiple actions", and then add a sequence of two actions: first, run a snippet, then show a popup.
Photo of Sofware Developer Guy

Sofware Developer Guy

  • 1,384 Points 1k badge 2x thumb
I am running into a similar situation, in which I am trying to load a popup and I need to run javascript to hide / initialize certain items on the page.  However, the popup is using a page include.  The page Include by itself works great as I have an in-line javascript code that runs and initializes everything.  However, when I put it inside the popup and call it from another location it doesn't work, its as if the initialization code is not running.

I've tried the action framework as well, by calling an initialization script after the pop-up action.  I get the same results.

Any ideas? Thank you.
Photo of Peter Kong

Peter Kong, Employee

  • 596 Points 500 badge 2x thumb
Archiving this post, but this discussion is good for future reference!

Please reference the new conversation here: Setting context of a Page Include
Photo of Zach McElrath

Zach McElrath, Employee

  • 53,784 Points 50k badge 2x thumb
Is the initialization code inside a wrapper like this:

 skuid.$(function(){
     // code here
});

Or something like that?

If so, place it inside of a block like this:

skuid.$(document.body).one('pageload',function(){
   // code here
});

This conversation is no longer open for comments or replies.