You need to sign in to do that
Don't have an account?
Karleen Mendoza
Update field on master object if checkbox is marked true on junction object
Hi all, I am having issues with getting a field to update. I want to pull in the "primary contact" of an account onto a custom object record (policy). After figuring out some limitations with field updates and the relationships, I have come to the conclusion that I can do a Flow and a few formula fields. BUT it's not working.
Here are the relationships heirarchy (to make things easier, I'll label them as A, B, C, and D.:
My thoughts are if I can get the field from the B record onto the A record, I can create display the info via Formula field
So, what I've done so far:
I think there's something off with either my Flow or the WFR but don't know what I'm doing wrong!
Here are the relationships heirarchy (to make things easier, I'll label them as A, B, C, and D.:
- Account (A) >> Account/Contact (B) (junction object. we have contacts that link to multiple accounts) >>
- Contact (C)
- Account >> Policy (D)
My thoughts are if I can get the field from the B record onto the A record, I can create display the info via Formula field
So, what I've done so far:
- Created a Formula field on the B record, to convert the contact ID to an actual name (pulled from C record).
- Created a Text field on the D record to house the value from the Flow
- Created a Text field on the A record to house the info pulled from B record using a Flow update
- Created a Flow and PB Workflow to update the A record with the info from B record, D record then gets updated via Formula
I think there's something off with either my Flow or the WFR but don't know what I'm doing wrong!
The big problem is to update correctly the parent (A) from the children updates (B). The flow can become quickly tricky
PROCESS BUILDER & FLOW: UPDATE PARENT STATUS BASED ON CHILD STATUSES (more complicated than your case):
https://seanbooksfdcdotcom.wordpress.com/2017/03/05/process-builder-flow-update-parent-status-based-on-child-statuses/
You have already used tricky flows in the past.
At what step that doesn't work as desired? (change of a "primary contact" of an account into the junction object ?)
APEX Trigger to Concatenate Records (from a Custom Object) and insert the Record Names into a field on the Account.
https://developer.salesforce.com/forums?id=9060G000000MOdLQAW
Thanks for the reply. I'm not too keen with APEX so using a flow would be better. LOL
I'd need it to update when the "primary contact" checkbox is checked on the junction object - if there are multiple account/contact relationships on the account.
I'll try the Flow example you gave me and let you know how it goes!
I am well aware that you prefer flows instead of some apex code and the second post is an alternative with a flow precisely (only the title is about apex). The flows work sometimes strangely and we need double arrow (otherwise that doesn't work as desired).
So here's what I've started based on the link you provided:
Do I need the Assignment element still if I can just assign it the Record Update?
Also, I need this filter in the Fast Lookup correct? The field is the account ID (via lookup) on the junction object. That's how we match correct?
What's working:
If there is no primary contact already on account and a contact is then marked as a primary contact - the field updates and shows Contact A
What's not working:
If a Contact A is in the field, but then when the primary contact is changed to Contact B - it does not update.
For example:
If Contact A was checked as the primary contact when the Account was created - then if you change the primary contact to Contact B. Nothing happens, it does not update. BUT if you delete the value of the field (that gets updated) and change the primary contact to Contact A again, it puts the value in the field...
Not sure it is exactly your case but that works.
if one relationship is marked "is Primary", the primary contact is updated or nullified into the related Account:
if there is no relationship with isPrimary__c = true, the collection is empty {!AccountContactRelatCollection} and has a value "null".
Then we just test this value in the decision.
{!AccountContactRelatCollection} is null (false) (not empty) and {!AccountContactRelatCollection} is null (true) (empty)
If there is no relationship with is Primary = true, we nullify the Primary_Contact__c with an empty string.
Otherwise, there is loop because there could have many Primary contact (wrong use) :
var_AccountId is an input/output variable in the flow and we just initialize this variable with Account_Contact_relationship__c.Account.Id
In fact, if you want to use only the process to trigger the flow, you need to add a checkbox "isActive__c" in Account_Contact_relationship__c and prevent the deletion of active rows. The user must deactivate the row of Account_Contact_relationship__c at first and then the deletion is possible.
This action is an update and can be used easily in the flow.
But to prevent this deletion of active rows, you need a minimal ... trigger (three lines of apex code). There is no alternative here.
https://success.salesforce.com/ideaView?id=08730000000DlPBAA0
and Fast Lookup with : Account__c = {!var_AccountId} and isPrimary__c = true and isActive__c = true
Then all I need to do is have a validation rule on account/contact object to prevent it from having more than one primary contact.
The loop is useless indeed as I wrote (bad use with multiple primary contact without a validation rule).
But it is interesting to know now what happens when you delete the complete row of Account_Contact_Relationship__c because nothing is fired for the process and the primary contact will remain in the account but there is perhaps a simple solution that you have used.