Letter varaiables

Posted by ionacaerex on 23-Jan-2017 12:55

I have a database relationship of customer to product, and product to provider (note no direct link from customer to provider).

I need to generate a letter to the customer but need to include provider level fields/data. How do I insert the appropriate variables from the provider?

Please go easy as non technical novice...

Many thanks

Posted by mpiscoso@gmail.com on 27-Jan-2017 23:32

Indeed pcs, thank you for addressing that.

To further the discussion, formulas are real-time "virtual fields" that aren't saved in the database as values but rather as script and are only processed and computed when the field is viewed/used/shown. This also means that you can't query formulas unlike reguar field types or expressions.

Do note that while formulas might be appropriate for this requirement, i would not reccomend their use for other use cases due to their nature of processing on-demand which can be taxing performance wise if a formula contains complex script.

There are other options to address your case such as creating actual fields on the product object and having triggers populate them from the provider object. It would only differ on how you want to use these fields.

E.g. if you don't need to query them and this is one of the few places that you'll use them, go with formulas, else, go with creating actual fields.

Hope that helps.

Posted by ionacaerex on 28-Jan-2017 04:53

Thanks very much all worked fine - will keep in mind the potential performance impact too

All Replies

Posted by mpiscoso@gmail.com on 23-Jan-2017 22:52

Hello and Good Day,

I can only assume that you have some sort of action or trigger in the customer object that would send a "letter" or email or template to your customer.

Given that, I can say that probably the easiest way to get Provider level fields or data from the Customer side is to create formula fields within the Product object that you can access from the Customer.

ex. Provider Name, the formula would look something like:

//Create a formula field on the product object that would return the Provider's name

return "{!R1234.name#text}";

from the customer's side, when editing the template for your letter, you should go to Related Product and look for your newly created formula fields and use them as you please.

ex. {!R4567.Provider_Name}

Hope this helps.

Piscoso, Martin

Posted by ionacaerex on 27-Jan-2017 09:24

Hi Thanks for the answer but what happens when I change the provider details - I am assuming they will not be updated at product level unless I update product?

Thanks

Posted by pcs on 27-Jan-2017 16:28

Hi,

Formula fields (as suggested by Martin) are dynamic and will reflect the latest changes to the provider object. Expressions on the other hand store the derived data. From the documentation "Expression field values are updated when a record is updated, while formula field values update dynamically with any change."

Regards,

Peter

Posted by mpiscoso@gmail.com on 27-Jan-2017 23:32

Indeed pcs, thank you for addressing that.

To further the discussion, formulas are real-time "virtual fields" that aren't saved in the database as values but rather as script and are only processed and computed when the field is viewed/used/shown. This also means that you can't query formulas unlike reguar field types or expressions.

Do note that while formulas might be appropriate for this requirement, i would not reccomend their use for other use cases due to their nature of processing on-demand which can be taxing performance wise if a formula contains complex script.

There are other options to address your case such as creating actual fields on the product object and having triggers populate them from the provider object. It would only differ on how you want to use these fields.

E.g. if you don't need to query them and this is one of the few places that you'll use them, go with formulas, else, go with creating actual fields.

Hope that helps.

Posted by ionacaerex on 28-Jan-2017 04:53

Thanks very much all worked fine - will keep in mind the potential performance impact too

This thread is closed