0 votes

Efficy 11.2 comes with RPC functions variable

Could someone describe me a use case of this operation? I honestly have no idea what it could be used for

asked in WorkFlow / Serverscript by (7.4k points)

2 Answers

+2 votes

The goal is to create "variables" that are stored for the duration of the RPC request.

This can be useful if the request contains several operations (e.g. create a Company, then do something with the created company), and you need to pass a value from an operation (e.g. the key of the created Company) to the next operation.

You can use the variables by enclosing their name between $$ tokens ($$xxxx$$).

For example, inside the company "edit" for creating the company you would add the following to store the company key:

{"@name": "variable", "name":"companyKey", "kind":"field", "fieldname":"K_COMPANY"}

To reuse the value later, e.g. in a "addlink", you could do the following:

{"@name": "addlink", "entity": "Cont", "key": "33", "detail": "Comp", "detailkey": "$$companyKey$$"}
answered by (1.2k points)
Wow, that's interesting!
This feature has been available since 2006, unfortunately without being documented. I guess it's never really been used :(.
So, now it's used :-)
+2 votes

Here is a nice example of how the RPC functions variable function can be used to insert a contact and link it direclty to a campaign record, in one single RPC request. I like it very much :-)

[
    {
        "@name": "edit",
        "closecontext": true,
        "commit": true,
        "entity": "Cont",
        "key": 0,
        "@func": [
            {
                "@name": "update",
                "tableview": "0",
                "@data": {
                    "BANNER": "Efficy Headquarters",
                    "NAME": "Doe",
                    "FIRSTNAME": "John",
                    "EMAIL1": "*Emails are not allowed*",
                    "PHONE2": "+32 111 111 222",
                    "MEMO": "Rue Colonel Bourg 122\n1140 Brussels\nBelgium"
                }
            },
            {
                "@name": "variable",
                "name": "k_Contact",
                "kind": "field",
                "fieldname": "K_CONTACT"
            }
        ]
    },
    {
        "@name": "api",
        "@func": [
            {
                "@name": "addlink",
                "entity": "Cont",
                "detail": "Publ",
                "key": "$$k_Contact$$",
                "detailkey": "8888001"
            }
        ]
    }
]
answered by (7.4k points)
1,247 questions
1,517 answers
1,858 comments
328 users