简体   繁体   中英

Salesforce retrieve object id using custom field on another object

We're implementing a coupon program. The coupons are unique codes and are related to an existing customer and stored in a custom field on the Account.

When a Lead is created due to being referred using one of the unique coupons, the unique coupon is saved in a custom field on the Lead. I need to access the associated Account Id of the unique coupon.

I could do this by creating a trigger on lead insert and then query accounts looking for unique coupon. My concern with this approach is having a trigger and query on every lead created; seems this would not be good pratice - using so much resources for a rare situation

Is there another (better) approach; lookup?

Thanks

If you build the trigger correctly there should be no concern about resources. But it really depends on what you're trying to do with the Account data, I don't know the architecture though so you will need to give more details

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM