run action sequence from snippet

Pretty sure it’s g in the function.

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'};<br>skuid.events.publish('hellovent',obj);

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.


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.

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.

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…

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

Finally got back to this and it works beautifully.  Thanks.

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 = {<br>&nbsp; &nbsp; "ZipCode": "37408",<br>&nbsp; &nbsp; "TotalPounds": 4.5<br>};<br>skuid.actionSequences.getByName("GetShippingRate").run(namedInputs);


This is the supported way to invoke Action Sequences from JavaScript by name, passing in named inputs.

Perfect. Just updated my code. Thx

glad to hear it worked out!

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 

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.

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:

@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.

Hi Jayesh, I will email you directly to try to setup a web meeting to walk through this. 

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}}

Jayesh, thank you for the feedback, happy to hear that you and Zach could solve the issue!

As of Skuid 12, .run() supports 2 parameters as follows:

skuid.actionSequences.getByName(“WriteLogSequence”).run(namedInputs, context);where context looks like:<br alt="" name="" rel="" target="" title="" type="" value="" /><pre alt="" name="" rel="" target="" title="" type="" value="">{ 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.

Can you please add this to the documentation.