You need to sign in to do that
Don't have an account?
RadDude89
Compare value on current contact record against all other contact records
Hi,
We are trying to add logic into our apex class where if the user registers a site and the mobile phone value held at contact is found on any other contact records it will update a field on registration.
So below I have these 2 lists.
listregQry= this contains the mobilephone from the contact being registered.
listregMobile= this contains all Mobile Phone values from our system
listregQry=[Select site__r.Contact__r.MobilePhone from Registrations__c where Id in : lstRegistrations ];
listregMobile=[Select Contact__r.MobilePhone from Site__c];
What I want to do is update a field called Mobile Used to TRUE when the Mobile Phone from listregQry is found on the system on a different contact record.
Does anyone know how I can achieve this?
Thanks in advance.
We are trying to add logic into our apex class where if the user registers a site and the mobile phone value held at contact is found on any other contact records it will update a field on registration.
So below I have these 2 lists.
listregQry= this contains the mobilephone from the contact being registered.
listregMobile= this contains all Mobile Phone values from our system
listregQry=[Select site__r.Contact__r.MobilePhone from Registrations__c where Id in : lstRegistrations ];
listregMobile=[Select Contact__r.MobilePhone from Site__c];
What I want to do is update a field called Mobile Used to TRUE when the Mobile Phone from listregQry is found on the system on a different contact record.
Does anyone know how I can achieve this?
Thanks in advance.
Just try this out :
Let me know if this helps !
Thanks,
Apoorv
Hi Apoorv,
Thanks for the reply however when I try to compile the class I get the error message
Variable does not exist: Contact__r.MobilePhone
I'm getting that error from this line:
mobSet.add(Contact__r.MobilePhone);
I also need to add into my condition that the total number of mobile phones found is greater than 1 (to exclude the one that we are currently registering.
Let me know how it works out for you.
Apoorv, that works now thanks.
I just need to add in another condition to ensure that the mobile phone number is returned more than - do you know how I would add that?
Let me know if this works out for you.
Hi Apoorv,
Apologies for the delay - When I add in the code below I get the error message :Illegal assignment from List<Id> to List<Site__c>
for(Registrations__c r:listregQry){
if(mobMap.containsKey(r.site__r.Contact__r.MobilePhone)){
List<Site__c> siteList = mobMap.get(r.site__r.Contact__r.MobilePhone);
Try this out
Please mark this question as Solved if this answers your question, so that others can view it as a proper solution.
Thanks,
Apoorv