Button action, differences between Action 'Custom: Run Skuid Snippet' and 'Run multiple actions > Run a Skuid Javascript Snippet'

  • 1
  • Problem
  • Updated 4 years ago
  • Solved
Hi,

I have a button to run an in-Line snippet to compose a conga composer url and then launch the url, is working without problems:

This is before the merge:
https://composer.congamerge.com?sessionId={{$Api.Session_Id}}&serverUrl={{$Api.Partner_Server_Url}}&id={{Id}}&ReportVar={{Id}}
&QVar0Id=a0C17000000Et3N?pv0={{Id}}
&QVar1Id=a0C17000000Et3I?pv0={{Id}}
&QueryId=[OPPOwner]a0C17000000EwWW?pv0={{OpportunityID__c}},
[Site]a0Cb0000006CSH3?pv0={{{Site__r.Id}}},
[FirstOrderContact]a0C170000009Ty9?pv0={{Id}},
[OrderContact]a0Cb0000006CSGt?pv0={{Id}},
[TechContact]a0Cb0000006CSHD?pv0={{Id}},
[AdminContact]a0Cb0000006CSGj?pv0={{Id}},
[BillingContact]a0Cb0000006CSHI?pv0={{{Billing_Account__r.Id}}},
[BillingAccount]a0Cb0000006CSGo?pv0={{{Billing_Account__r.Id}}},
[Account]a0Cb0000006CSGe?pv0={{AccountID__c}}&
TemplateId=015b0000000mYRt&OFN=Service+Order+Form+{{Order_ID_show__c}}
&EmailToId={QVar0}
&EmailAdditionalTo={QVar1}
&CongaEmailTemplateID=a0A17000000DSfq
&EmailRelatedToId={{Id}}
&MFTS0=Stage__c
&MFTSValue0=Order+form+sent
&LG1=Order+Form+Sent
&LG3=1&LG4=2&DS7=2
This is after the merge:
https://composer.congamerge.com?sessionId=[...]&serverUrl=[...]&id=a04b000000CaWygAAF
&ReportVar=a04b000000CaWygAAF
&QVar0Id=a0C17000000Et3N?pv0=a04b000000CaWygAAF
&QVar1Id=a0C17000000Et3I?pv0=a04b000000CaWygAAF
&QueryId=[OPPOwner]a0C17000000EwWW?pv0=006b0000007nYDk,
[Site]a0Cb0000006CSH3?pv0=a0Fb0000007ikZcEAI,
[FirstOrderContact]a0C170000009Ty9?pv0=a04b000000CaWygAAF,
[OrderContact]a0Cb0000006CSGt?pv0=a04b000000CaWygAAF,
[TechContact]a0Cb0000006CSHD?pv0=a04b000000CaWygAAF,
[AdminContact]a0Cb0000006CSGj?pv0=a04b000000CaWygAAF,
[BillingContact]a0Cb0000006CSHI?pv0=00117000001vAA0AAM,
[BillingAccount]a0Cb0000006CSGo?pv0=00117000001vAA0AAM,
[Account]a0Cb0000006CSGe?pv0=001b000000RxhHX
&TemplateId=015b0000000mYRt
&OFN=Service+Order+Form+OR-019292
&EmailToId={QVar0}
&EmailAdditionalTo={QVar1}
&CongaEmailTemplateID=a0A17000000DSfq&
EmailRelatedToId=a04b000000CaWygAAF
&MFTS0=Stage__c
&MFTSValue0=Order+form+sent
&LG1=Order+Form+Sent
&LG3=1&LG4=2&DS7=2
All the {{ fields }} are merged with the values.

But, If I change the action of the button to 'Run Multiple Actions' and one of the actions is to run the snippet the merge fails (bolded the missing merges):
https://composer.congamerge.com?sessionId=[...]&serverUrl=[...]
&id=a0h17000001AzH2AAK
&ReportVar=a0h17000001AzH2AAK
&QVar0Id=a0C17000000Et3N?pv0=a0h17000001AzH2AAK
&QVar1Id=a0C17000000Et3I?pv0=a0h17000001AzH2AAK
&QueryId=[OPPOwner]a0C17000000EwWW?pv0=, <<<---{{OpportunityID__c}}
[Site]a0Cb0000006CSH3?pv0=,  <<<---{{{Site__r.Id}}}
[FirstOrderContact]a0C170000009Ty9?pv0=a0h17000001AzH2AAK,
[OrderContact]a0Cb0000006CSGt?pv0=a0h17000001AzH2AAK,
[TechContact]a0Cb0000006CSHD?pv0=a0h17000001AzH2AAK,
[AdminContact]a0Cb0000006CSGj?pv0=a0h17000001AzH2AAK,
[BillingContact]a0Cb0000006CSHI?pv0=,   <<<--- {{{Billing_Account__r.Id}}}
[BillingAccount]a0Cb0000006CSGo?pv0=,   <<<--- {{{Billing_Account__r.Id}}}
[Account]a0Cb0000006CSGe?pv0=   <<<--- {{AccountID__c}}
&TemplateId=015b0000000mYRt
&OFN=Service+Order+Form+    <<<--- {{Order_ID_show__c}}
&EmailToId={QVar0}
&EmailAdditionalTo={QVar1}
&CongaEmailTemplateID=a0A17000000DSfq
&EmailRelatedToId=a0h17000001AzH2AAK
&MFTS0=Stage__c
&MFTSValue0=Order+form+sent
&LG1=Order+Form+Sent
&LG3=1&LG4=2&DS7=2

I have the 5.21.4 (just updated) I don't know if this happened in previous versions (i haven't tested yet in one of my sandboxes with the 5.21.2)
Photo of Pablo Martinez

Pablo Martinez

  • 2,468 Points 2k badge 2x thumb

Posted 4 years ago

  • 1
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
Do you have any actions that do anything to the models prior to the snippet running? Screenshot of the actions please.
Photo of Pablo Martinez

Pablo Martinez

  • 2,468 Points 2k badge 2x thumb
Hi Pat,

I have actions before, I tested it and if the first action is the snippet there's no problem,

The other actions I have is create a record in other model (nothing to do with the fields I asking in the snippet) and save it:
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
hmmmm ... I'd have to look see but only Skuid guys can do that.

I've noticed that it's all the related IDs but not the row in context. That being the contact. hmmmm...

It's as if all the other models fall out of context. Weird.
Photo of Pablo Martinez

Pablo Martinez

  • 2,468 Points 2k badge 2x thumb
yeah I thought that, as if the "main" model fails but the Id field is working and all the fields requested are in the model definition, and no only lookup fields fail, normal fields also fail.
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
I think the problem is not with your snippet.  It is with the model you have in context.  Context can be very tricky - and we have not exposed good ways for you to see what record and data is in context as you traverse through a set of actions. 

You are expecting the merges to be filled with data from the model connected to the page title where this button is located.  This is what we typically think of as context. 

But what happens is that as soon as you create a new row in your action sequence,  the context switches to that new row and merges bring in the wrong data or none at all. 

So either move your conga action up in your sequence,  or use global data merge syntax in your snippet - as in: {{$Model.ModelName.data.0.FieldName}} This will ignore context and simply bring in data as needed.  (This won't work if you are trying to bring in particular row data in a multi record scenario)

Hopefully this clears some things up. 

But to answer your question.  There should be no difference between a Snippet executied directly as a button action, and executied as the single action of a Multiple Actions chain. 
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
That explains it. The row in context changes. The IDs that did merge should then be in relation to the row that was just created in the above actions.
Photo of Pablo Martinez

Pablo Martinez

  • 2,468 Points 2k badge 2x thumb
Ahhh ok, thanks for the explanation Rob!
Photo of Pablo Martinez

Pablo Martinez

  • 2,468 Points 2k badge 2x thumb
You can mark it as solved :D 

I have decided put the conga url at the beginning, the other actions were only to store "you have sent the document", so nevermind if it's before or after the conga composer pop up