-
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='hire@gmail.com'; 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

Mass Inline Editor - No More AppExchange tools or VF/Apex customizations!
The long wait is over now! Mass Inline Editing comes to Lightning Experience! Finally, this news will excite many of our Salesforce Customers around…

Related Records Updation with the Help of Salesforce Flow
Hello all, In this blog, we will get to know how to update records using Salesforce flow. For updating the related object records we can…
Popular Salesforce Videos
Using Lambdas to Overcome Salesforce Governor Limits
Salesforce is a great CRM product, but it has some limitations that can prove troublesome depending on the situation. Since each org has to share…
Salesforce for Manufacturing: How to Digitize Your Sales Processes
As a manufacturing sales leader, you’re looking for ways to go digital with your sales processes and improve channel performance. In this video, you’ll learn…
Salesforce Marketing Cloud Connect: Subscriber Key Migration
We demo how leveraging a subscriber key migration to remove duplicate subscribers from Sales or Service Cloud in Marketing Cloud while minimizing data loss. Explore…
Popular Salesforce Infographics

Build On Your Salesforce Service Cloud With Cognitive Search
Employees waste around 20% of their time looking for information to do their job. That’s a lot, isn’t it? This means there is one giant…

How Salesforce is Beneficial For Your Business
There is a saying frequently heard many times which is “ Customer is a King”. So, a business needs to do everything to satisfy the…

ABC's of Salesforce's Apex Coding Language
Apex is a proprietary language developed by Salesforce.com. It is a strongly typed, object-oriented programming language that allows developers to execute flow and transaction control…