Redirect to URL Action with Aggregate Variable Doesn't Work?

  • 1
  • Problem
  • Updated 1 year ago
  • Solved
I have a page with a model that holds a user's list of courses they're registering for, each with a price. I then have a model that uses the same data, except in the aggregate, in order to get the sum of all courses. I'm then trying to redirect to a PayPal URL and supply that total to the URL string.

I have tried both:
http://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_xclick&business=XXXXX&lc=US&item_name=Test&amount={{{sumCourseOfferingrMemberP}}}
and:
http://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_xclick&business=XXXXX&lc=US&item_name=Test&amount={{{$Model.RequestTotals.data.0.sumCourseOfferingrMemberP}}}
If I use:
http://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_xclick&business=XXXXX&lc=US&item_name=Test&amount=123
It works fine. If I include the same variable in the button label, it works fine. Are Redirect to URL actions unable to read aggregate fields?

My next step is to write a snippet that copies that value to a real field and read from there, but I'm hoping to not have to go that route.
Photo of Seth Leonard

Seth Leonard

  • 662 Points 500 badge 2x thumb

Posted 2 years ago

  • 1
Photo of Mark DeSimone

Mark DeSimone, Official Rep

  • 12,066 Points 10k badge 2x thumb
Hi Seth,

What does the resulting URL look like when you try the first two options you have here?

Perhaps before resorting to using a snippet, you might be able to add a UI-only formula field to your model that outputs the desired text for the URL, and pulls in the value of the aggregate field you're after. 
Photo of Seth Leonard

Seth Leonard

  • 662 Points 500 badge 2x thumb
Resulting URL has blank value in place of variable, though there was a version with another following variable (&var=val) that was weird; it cut off the &var part.

Will try the UI-only field and report back. Thanks!
(Edited)
Photo of Mark DeSimone

Mark DeSimone, Official Rep

  • 12,066 Points 10k badge 2x thumb
Hmm, I tried this with a very simple page (XML below), and was able to get the sum field's value into the URL of a template field. The Redirect to a URL seems to work on this test page too. You're right to be using triple mustaches around the field. I'd check to make sure the page component that's holding your redirect action (whether it's a button set, page title, or other action) is connected to the correct model, otherwise that field reference won't have the right context. Also, be sure that the field name you're using matches up with what's on the model, as aggregate models will rename fields to account for the kind of aggregation that's being done. 

<skuidpage unsavedchangeswarning="yes" personalizationmode="server" showsidebar="true" useviewportmeta="true" showheader="true">    <models>
        <model id="Opp" limit="" query="true" createrowifnonefound="false" datasource="salesforce" type="aggregate" sobject="Opportunity" orderby="">
            <fields>
                <field id="Amount" name="sumAmount" function="SUM"/>
            </fields>
            <conditions/>
            <actions/>
            <groupby method="simple"/>
        </model>
        <model id="OppB" limit="20" query="true" createrowifnonefound="false" datasource="salesforce" type="" sobject="Opportunity">
            <fields>
                <field id="Account.Name"/>
                <field id="Amount"/>
                <field id="Description"/>
            </fields>
            <conditions/>
            <actions/>
        </model>
    </models>
    <components>
        <buttonset uniqueid="sk-1dlvxM-113" model="Opp">
            <buttons>
                <button type="redirect" label="Redirect {{{sumAmount}}}" icon="" window="blank" url="http://www.google.com/sumAmount"/>;
            </buttons>
        </buttonset>
        <basicfieldeditor showheader="true" showsavecancel="false" showerrorsinline="true" model="Opp" buttonposition="" uniqueid="sk-1dizO5-121" mode="read">
            <columns>
                <column width="50%">
                    <sections>
                        <section title="Section A">
                            <fields>
                                <field id="Amount" name="sumAmount" decimalplaces="" valuehalign="" type=""/>
                            </fields>
                        </section>
                    </sections>
                </column>
                <column width="50%">
                    <sections>
                        <section title="Section B" collapsible="no">
                            <fields>
                                <field type="COMBO" valuehalign="" editmodebehavior="autopopup" allowhtml="true">
                                    <label>Template Field</label>
                                    <template>&lt;a href="http://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_xclick&amp;business=XXXXX&amp;lc=US&am... is the link&lt;/a&gt;</template>
                                </field>
                            </fields>
                        </section>
                    </sections>
                </column>
            </columns>
        </basicfieldeditor>
        <skootable showconditions="true" showsavecancel="true" showerrorsinline="true" searchmethod="server" searchbox="true" showexportbuttons="false" pagesize="10" createrecords="true" model="OppB" buttonposition="" mode="read" allowcolumnreordering="true" uniqueid="sk-1djZ0H-181">
            <fields>
                <field id="Account.Name" hideable="true" uniqueid="fi-1djg8T-200"/>
                <field id="Amount" hideable="true" uniqueid="fi-1djg8U-201"/>
                <field id="Description" hideable="true" uniqueid="fi-1djg8U-202"/>
            </fields>
            <rowactions>
                <action type="edit"/>
                <action type="delete"/>
            </rowactions>
            <massactions usefirstitemasdefault="true">
                <action type="massupdate"/>
                <action type="massdelete"/>
            </massactions>
            <views>
                <view type="standard"/>
            </views>
        </skootable>
    </components>
    <resources>
        <labels/>
        <javascript/>
        <css/>
    </resources>
    <styles>
        <styleitem type="background" bgtype="none"/>
    </styles>
</skuidpage>
(Edited)
Photo of Seth Leonard

Seth Leonard

  • 662 Points 500 badge 2x thumb
Thanks, Mark. I have been able to get it to work in a simple page (see below), so I'm doing something else wrong. However, I am noticing a separate issue that is also not helping with PayPal. If I use the aggregate variable in the URL, it formats other parts of the string as a special character, namely the &curren in &currency.

If I use the variable, it goes to:
https://www.skuid.com/test/?total=32&test=1%C2%A4cy=USD
If I hard-code the value, it goes to:
https://www.skuid.com/test/?total=123&test=1&currency=USD
If you have an active campaign with an actual cost value, you'll see the same using this page. Any ideas?
<skuidpage unsavedchangeswarning="yes" personalizationmode="server" showsidebar="true" useviewportmeta="true" showheader="true">
    <models>
        <model id="AggModel" limit="1" query="true" createrowifnonefound="false" datasource="salesforce" type="aggregate" sobject="Campaign">
            <fields>
                <field id="ActualCost" name="sumActualCost" function="SUM"/>
            </fields>
            <conditions>
                <condition type="fieldvalue" value="true" enclosevalueinquotes="false" field="IsActive"/>
            </conditions>
            <actions/>
            <groupby method="simple">
                <field id="IsActive" name="isActive"/>
            </groupby>
        </model>
    </models>
    <components>
        <buttonset model="AggModel" uniqueid="sk-1i9ifO-124">
            <buttons>
                <button type="redirect" label="Agg Value in Direct Button" window="blank" url="https://www.skuid.com/test/?total={{{sumActualCost}}}&amp;test=1&amp;currency=USD"/>
                <button type="multi" label="Agg Value in Multi-Action">
                    <actions>
                        <action type="redirect" window="blank" url="https://www.skuid.com/test/?total={{{sumActualCost}}}&amp;test=1&amp;currency=USD"/>
                    </actions>
                </button>
                <button type="redirect" label="Hard-Coded Value in Direct Button" window="blank" url="https://www.skuid.com/test/?total=123&amp;test=1&amp;currency=USD"/>
            </buttons>
        </buttonset>
    </components>
    <resources>
        <labels/>
        <javascript/>
        <css/>
    </resources>
    <styles>
        <styleitem type="background" bgtype="none"/>
    </styles>
</skuidpage>
Photo of Mark DeSimone

Mark DeSimone, Official Rep

  • 12,066 Points 10k badge 2x thumb
Hi Seth,

Thanks for the example XML -- I see what you mean. It looks like you need to encode the ampersand in the URL so it's handled right when using the variable. Using &amp; instead of &, and that seems to form the URL correctly. The behavior is inconsistent, as you describe, so I will bring it up with our dev team. For the present, using &amp; should work. 
Photo of Seth Leonard

Seth Leonard

  • 662 Points 500 badge 2x thumb
Thanks! And I think I found the bug. See the page below. If in a multi-action I create a new row in an unrelated model before I redirect, the total disappears. If there is no new row creation, or it happens after the redirect, the total stays. Not sure why row creation in an unrelated model affects this at all. Another bug for the team?
<skuidpage unsavedchangeswarning="yes" personalizationmode="server" showsidebar="true" useviewportmeta="true" showheader="true">
    <models>
        <model id="AggModel" limit="1" query="true" createrowifnonefound="false" datasource="salesforce" type="aggregate" sobject="Campaign">
            <fields>
                <field id="ActualCost" name="sumActualCost" function="SUM"/>
            </fields>
            <conditions>
                <condition type="fieldvalue" value="true" enclosevalueinquotes="false" field="IsActive"/>
            </conditions>
            <actions/>
            <groupby method="simple">
                <field id="IsActive" name="isActive"/>
            </groupby>
        </model>
        <model id="Account" limit="1" query="false" createrowifnonefound="false" datasource="salesforce" type="" sobject="Account">
            <fields>
                <field id="Name"/>
                <field id="BillingStreet"/>
            </fields>
            <conditions>
                <condition type="fieldvalue" value="Test Organization" enclosevalueinquotes="true" field="Name"/>
            </conditions>
            <actions/>
        </model>
    </models>
    <components>
        <buttonset model="AggModel" uniqueid="sk-1i9ifO-124">
            <buttons>
                <button type="redirect" label="Agg Value in Direct Button" window="blank" url="https://www.skuid.com/test/?total={{{sumActualCost}}}&amp;test=1&amp;currency=USD"/>
                <button type="multi" label="Agg Value in Multi-Action, Create First">
                    <actions>
                        <action type="createRow" model="Account" appendorprepend="prepend" defaultmodefornewitems="edit" affectedrows="context">
                            <defaults>
                                <default type="fieldvalue" field="BillingStreet" enclosevalueinquotes="true" value="111 Main Street"/>
                            </defaults>
                        </action>
                        <action type="redirect" window="blank" url="https://www.skuid.com/test/?total={{{sumActualCost}}}&amp;test=1&amp;currency=USD"/>
                    </actions>
                </button>
                <button type="multi" label="Agg Value in Multi-Action, Redirect First">
                    <actions>
                        <action type="redirect" window="blank" url="https://www.skuid.com/test/?total={{{sumActualCost}}}&amp;test=1&amp;currency=USD"/>
                        <action type="createRow" model="Account" appendorprepend="prepend" defaultmodefornewitems="edit" affectedrows="context">
                            <defaults>
                                <default type="fieldvalue" field="BillingStreet" enclosevalueinquotes="true" value="111 Main Street"/>
                            </defaults>
                        </action>
                    </actions>
                </button>
            </buttons>
        </buttonset>
    </components>
    <resources>
        <labels/>
        <javascript/>
        <css/>
    </resources>
    <styles>
        <styleitem type="background" bgtype="none"/>
    </styles>
</skuidpage>
Photo of Mark DeSimone

Mark DeSimone, Official Rep

  • 12,066 Points 10k badge 2x thumb
Seth, we have reproduced this behavior as well, and appreciate your illustration and explanation. This and the ampersand issue discussed above have both been brought to the attention of our dev team, and we will update this post when a fix is available. 
Photo of Stephen Sells

Stephen Sells, Alum

  • 17,326 Points 10k badge 2x thumb
Official Response
Hello Skuid Community ~

This has been addressed in the new Millau 11.1.3 and Brooklyn 10.0.17 release which is now available on the Skuid Releases page.

As a reminder, Salesforce does NOT allow reverting back to prior versions of managed packages. Skuid always recommends installing new versions in a non-business critical sandbox environment to test all mission critical functionality before installing into a production environment. We also recommend that you update out of date themes when you upgrade.

Please be reminded to read this version’s special release notes here.
(Edited)
Photo of Bill Fox

Bill Fox

  • 8,800 Points 5k badge 2x thumb
Hello Seth,

It is not clear what URL actually worked?

Cheers,
Bill Fox