Accessing information about secondary entities with GetContextInfo

Less than one minute read time.

Secondary entities are technically never in context so the GetContextInfo method doesn't work for these entities. For example if you wanted to get the current address id this would not work: GetContextInfo('address', 'addr_addressid');

However when you go into the edit screen of a secondary entity, like address, CRM puts the id of that entity into the query string. You can access values in the query string server side with the Values collection. So to get the current addr_addressid you can use Values('addr_addressid').

Note that only the address id is put into the query string. So if you want to access other information about the address you will need to use code like the following:

address = CRM.FindRecord('address', 'addr_addressid=' + Values('addr_addressid'));
city = address.addr_city;

Parents Comment Children
No Data