You need to sign in to do that
Don't have an account?
Traversing SOQL on Trigger - Related objects with Junction Object
Hi all,
I want to create a trigger which will update the name of a record:
Every time the related contact 'Primary Contact' is added to a Request:
Change the name of the Asset_Weeks which is related to the Week__c and Asset__c of the Request
The schema fort a bit of conext is :

I want to create a trigger which will update the name of a record:
trigger UpdateAssetWeek on Request__c (after update) { List<Asset_Weeks__c> a = new List<Asset_Weeks__c>(); for (Request__c req : Trigger.new){ if (req.Allocated_Week__c != NULL){ Asset_Weeks__c asswk = new Asset_Weeks__c(); asswk = [SELECT Id, Name FROM Asset_Weeks__c WHERE Week__c = 'Request__c.Allocated_Week__r.Asset_Week__c']; asswk.Name = asswk.Name + ' ' + req.Primary_Contact__c.Firstname + ' ' + req.Primary_Contact__c.Firstname; a.add(asswk); } } update a; } //Every time the related contact 'Primary Contact' is added to a Request: //Change the name of the Asset_Weeks which is related to the Week__c and Asset__c of the Request
Every time the related contact 'Primary Contact' is added to a Request:
Change the name of the Asset_Weeks which is related to the Week__c and Asset__c of the Request
The schema fort a bit of conext is :
Asset_Weeks__c is changed to Holiday_Booking__c for better UX.
All Answers
Asset_Weeks__c is changed to Holiday_Booking__c for better UX.