run action sequence from snippet

Pat VachonPat Vachon 💎💎💎
edited June 25, 2020 in Questions
How?

Comments

  • Pat VachonPat Vachon 💎💎💎
    edited June 25, 2020
    Two steps closer. Been able to get the object for the sequence I want and run it.

    var queryAllRecords = skuid.actionSequences.getByName('Query All Records');

    queryAllRecords.run();

    How can I set the inputs for the sequence. I assume I have to provide the parameters in the run function. Just dunno what format it needs.
  • Pat VachonPat Vachon 💎💎💎
    edited June 25, 2020
    Pretty sure it's g in the function.

    image
  • edited June 25, 2020
    Any reason against using the skuid.events to publish an event that'll kick off the action sequence? Via skuid.events it would just look something like this
    var obj = {dollars: "1500", pennies:'abc'};
    skuid.events.publish('hellovent',obj);
  • edited June 25, 2020
    We are using this:

            skuid.actionSequences.getByName("MyActionSequence").run()

                .then(function(newContext) {

     

                    //Actions after calling action here

     

                    console.log("outputs from Data Source Action", newContext.$PreviousAction.result);

                    });


    To pass inputs, we are setting variables in the snippet on a UI model and then merge the values into your action.

    For example, we use this heavily to create custom chatter posts.  So we have  'PostChatter' action sequence.  I've got a UI model that captures "Message" and Parent" (set via snippet) and then calls the action sequence to create the chatter post.


  • Pat VachonPat Vachon 💎💎💎
    edited July 17, 2018
    Hmmm ... seems intriguing. I'd like to get the best of all options where it's an Reusable Action Sequence for declarative reasons and an Event-triggered Sequence for javascript reasons.
  • Pat VachonPat Vachon 💎💎💎
    edited July 17, 2018
    Yup. I've had to resort to using a UI only model as well. Rather not, but alas I could not find a way to set inputs for the action sequence.
  • edited July 17, 2018
    Yeah it's works out well, and just to clarify the dollars/pennies were Inputs the action sequence was expecting. Just realized that I gave zero explanation for why that extra line was there...
  • Karen WaldschmittKaren Waldschmitt 🛠️ 
    edited July 23, 2018
    Thanks for sharing your ideas, Matt and Chandra. Glad you have a way to get it working, Pat! Will check in with our product management team about an easier way to do this ... 

    Thanks!
    Karen
  • Pat VachonPat Vachon 💎💎💎
    edited August 24, 2018
    Finally got back to this and it works beautifully.  Thanks.
  • edited June 25, 2020
    Pat / Chandra,

    As of the Millau U2 Release, we adjusted the syntax of the Action Sequences run() function to have named Action Framework Inputs be the first argument that run() accepts. So as of 11.2.x release, the recommended way to do this is the following:
    var namedInputs = {
        "ZipCode": "37408",
        "TotalPounds": 4.5
    };
    skuid.actionSequences.getByName("GetShippingRate").run(namedInputs);
    This is the supported way to invoke Action Sequences from JavaScript by name, passing in named inputs.
  • Pat VachonPat Vachon 💎💎💎
    edited August 23, 2018
    Perfect. Just updated my code. Thx
  • edited August 24, 2018
    glad to hear it worked out!
  • edited September 28, 2018
    Is this compatible/usable to submit an Apex Class?

    I am trying to pass Inputs values to a Action Sequence from this snippet script:


    var namedInputs = {
        "BaseModelName" : "",
        "ButtonName": "TestSubmit",
        "LayoutObjectName" : "",
        "LayoutObjectType" : "",
        "Message" : "This is a test from Skuid page : Snippet",
        "PageName": "Logging_Message__Test",
        "PopupName" : "",
        "SnippetName" : "newSnippet"
    };

    skuid.actionSequences.getByName("WriteLogSequence").run(namedInputs);


    The Action Sequence submits an Apex class (Invocable Method) matching the variables to the parameters on the method. 

    Issue is, the apex method is submitted, but no values passed from the Snippet.

    IF I set some default values on the Action Sequence , then apex method runs fine.

    Any idea?

    EDIT:   Skuid  version 11.2.6 
  • edited September 28, 2018
    Any updates on this? We are not able to pass parameters to action sequence as indicated in above scenario. This does not work in 11.2.9 also.
  • edited October 23, 2018
    Jayesh, just to confirm, you have defined a named Input for each of the parameters you are trying to pass in via the JavaScript snippet? 

    i.e. if you are trying to do this:
    var namedInputs = {
        "hello" : "world",
        "exchangeRate": 1.04,
        "Pizza" : "Mushroom",
    };
    skuid.actionSequences.getByName("WriteLogSequence").run(namedInputs);
    you would need to have declared these Inputs in your Action Sequence:

    image
  • edited January 30, 2019
    @Zach sorry for the delayed response on this but this is still an issue for us. We do have the inputs setup on the action sequence. We are also passing in the namedInputs similar to the snippet example you provided.
  • edited January 30, 2019
    Hi Jayesh, I will email you directly to try to setup a web meeting to walk through this. 
  • edited January 30, 2019
    Zach was kind enough to work with me on this issue. The critical piece of information I was missing was the syntax to refer to the the action sequence inputs in the actions tab section. So for the above e.g. you would refer to the input in the actions section as {{$Input.hello}}
  • Luzie BaumgartLuzie Baumgart 🛠️ 
    edited February 1, 2019
    Jayesh, thank you for the feedback, happy to hear that you and Zach could solve the issue!
  • Jer CarpenterJer Carpenter ✭✭
    edited April 11, 2019
    As of Skuid 12, .run() supports 2 parameters as follows:
    skuid.actionSequences.getByName("WriteLogSequence").run(namedInputs, context);
    where context looks like:
    { row: {}, model: {} }
    Prior to this, both namedInputs and context were expected as the 1st parameter, so this is a change in Skuid 12 (possibly dates back to 11.2, actually).  If you have a context object in your JS, this will allow your called action sequence to be context aware.
  • Pat VachonPat Vachon 💎💎💎
    edited June 25, 2020
    Can you please add this to the documentation.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!