-
Salesforce Trigger is not working, anyone help me with this code
Create object : Condidate__c
Fields : (All Text fields)
First Name
Last Name
Email
Brokerage
Manage Brokerage
Condidate Status (Webinar - Attended , Webinar -Not Attended)
User Created ( checkbox)
On insert:- Create Account if Brokerage !=null
- Create another account if Manage Brokerage != null and set parentId = Brokerage account id (created in 1 point)
- Create new contact record and set accountId = Manage Brokerage account id (created in 2 point)
- create new field condidate__c(lookup) on contact and fill it with Condidate__c record id
- Create task record for contact record (created in point 3)
Task.WhoId = contactId
Task.WhatId = Condidate__c
Task.Subject = 'Portal Contact Setup';
On Update :
if Condidate__c Status = Webinar - Attended and User Created = false ,
Create Portal user for Condidate child contact created in 3 point.trigger CreateContactcase on Hire_Form__c (before insert,before update){ list<Contact> conlist=new list<Contact>(); list<case> caselist=new list<case>(); if(trigger.isinsert){ for(Hire_Form__c hire:trigger.new){ if(hire.Status__c=='In Progress'){ Contact con=new Contact(); con.FirstName='Hire'; con.LastName='Trigger'; con.Email='[email protected]'; con.Phone='123456'; conlist.add(con); //hire.Candidate__c=con.Id; } } insert conlist; system.debug('=====>'+conlist); for(Contact con1:conlist){ case cc=new case(); cc.ContactId=con1.Id; cc.Status='New'; cc.Origin='Phone'; //cc.Id=conlist[0].Id; caselist.add(cc); } insert caselist; system.debug('=====>'+caselist); } if(Trigger.isupdate){ for(Hire_Form__c hire:trigger.new){ for(case c:caselist){ if(hire.Status__c=='completed' && hire.Status__c !=trigger.oldmap.get(hire.Id).Status__c){ c.Status='closed'; } } update caselist; system.debug('====>'+caselist); } } }
Log In to reply.
Popular Salesforce Blogs

Types of Salesforce Support (Customer Success) Plans You’ll See out in the Wild
Customer success is when the customers can achieve their desired business outcomes by leveraging the Salesforce platform. Providing a suitable customer success plan means providing…

How Salesforce is Responding to The COVID-19 Pandemic?
Governments and businesses worldwide have begun their COVID-19 vaccination programs to protect citizens from the continuously mutating virus, although they have grappled with multiple obstacles…

Salesforce Einstein: 6 Take-Aways from Salesforce Winter ’17 Release
Customer Relationship Management(CRM) continues to grow and with this rapid development comes the ever-rising demand for deeper and seamless interaction with the customers. With the…
Popular Salesforce Videos
Crash Course on Apex Triggers Salesforce | Complete Guide with Real Time Scenarios
Complete guide on Apex Triggers Salesforce 0:00 Intro 0:33 Is Triggers difficult to Learn 0:50 What is Trigger? 3:03 What are Trigger events? 11:55 How…
Is Salesforce A Good Career For Freshers?
Wondering whether Salesforce is a good career for freshers or not? Here are all your answers. Join this useful group for Salesforce job & career…
How To Become A Salesforce Administrator | Salesforce Administrator Training
What does Salesforce developer do? Salesforce developers lead the testing and implementation of software development efforts, including coding, configuration, maintenance, installation, testing, and debugging, as…
Popular Salesforce Infographics

Six Reasons Clients Love Salesforce Community Cloud
While there are way more than six reasons to love Salesforce Community Cloud, here are the top six reasons that keep coming up again and…

Why Integrate Your Pardot Account with Salesforce?
Salesforce Sales Cloud is primarily a sales tool while Pardot is a marketing automation platform. Both are designed to increase sales and maximize efficiency for…

How Salesforce Outsourcing Can Help Your Business Grow
We all know how beneficial is Salesforce for any business but people still wonder if it is beneficial to go for Salesforce Outsourcing services. This…