How to pass certain variables or objects in a link

Posted by gonzales.pgon@gmail.com on 11-May-2014 22:18

I have a link called "Pay" in the List View. When it is clicked, it goes to the Create New Receipt page. From the list view, I want to pass the statement at client object to the New Receipt page so that the user should not have to select the statement and client while in the New receipt page.

Posted by Santosh Patel on 12-May-2014 00:18

An HTML5 only solution for now. Let me know if that works for you.

I included a Template Text field called "Pay" with following template in the Statement Object

<a href='{!#LINK.receipt3#98338172}' onclick='localStorage.setItem("statementId", "{!id}");localStorage.setItem("statementName", "{!name#text}");'>Pay Now</a>

{!#LINK.receipt3#98338172} - Template token for New Receipt Page

Along with statement record ID and name in this case, you could set as many other values as you need.

Added following script in the New Receipt Page to set the Statement lookup field. You could add more javscript to set other fields that you would like to have preset.

<script>
rbf_selectObject(localStorage.getItem('statementId'),localStorage.getItem('statementName'),-1, "R98338384",false);
</script>

You can decipher values in the template helper as follows
rbf_selectObject(relatedObjectId, relatedObjectRecordName, viewPageId, relationshipname, ismultiselect)

viewPageId - not required here
relationshipname - Related Statement > Relationship Name. This will give you the string to use
ismultiselect - self explanatory


Regards,

Santosh

All Replies

Posted by Santosh Patel on 12-May-2014 00:18

An HTML5 only solution for now. Let me know if that works for you.

I included a Template Text field called "Pay" with following template in the Statement Object

<a href='{!#LINK.receipt3#98338172}' onclick='localStorage.setItem("statementId", "{!id}");localStorage.setItem("statementName", "{!name#text}");'>Pay Now</a>

{!#LINK.receipt3#98338172} - Template token for New Receipt Page

Along with statement record ID and name in this case, you could set as many other values as you need.

Added following script in the New Receipt Page to set the Statement lookup field. You could add more javscript to set other fields that you would like to have preset.

<script>
rbf_selectObject(localStorage.getItem('statementId'),localStorage.getItem('statementName'),-1, "R98338384",false);
</script>

You can decipher values in the template helper as follows
rbf_selectObject(relatedObjectId, relatedObjectRecordName, viewPageId, relationshipname, ismultiselect)

viewPageId - not required here
relationshipname - Related Statement > Relationship Name. This will give you the string to use
ismultiselect - self explanatory


Regards,

Santosh

Posted by lCira9 on 12-May-2014 02:20

It worked. Thank you very much!

Posted by lCira9 on 12-May-2014 07:44

Wait. There's a problem. Although the statement is put in the Statement Lookup field, the statement is not saved on the receipt when the new receipt is saved.

Posted by Santosh Patel on 12-May-2014 10:05

In my example setup, the lookup field seems to be saving fine. If you are developing on the public cloud I could take a look at your setup and check for any errors.

Please share your userID if that is the case.

Posted by lCira9 on 12-May-2014 19:19

Hi Santosh,

I got it working already. The problem was on the statement ID while setting the link

    localStorage.setItem("statementId", "{!statement_id}")

It is because that we have another id (statement_id) in our table. Thank you very much for all the help!

Posted by lCira9 on 12-May-2014 19:19

I got it working already. The problem was on the statement ID while setting the link

    localStorage.setItem("statementId", "{!statement_id}")

It is because that we have another id (statement_id) in our table. Thank you very much for all the help!

This thread is closed