-
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
![](https://images.forcetalks.com/wp-content/uploads/2023/05/04164043/sa_16832183085%20Productivity%20Tips%20by%20Salesforce%20System%20Administrators-1024x577.jpg)
5 Productivity Tips by Salesforce System Administrators
Salesforce is a highly transformative platform when used correctly. It has all the tools you need to build and optimize processes. But achieving productivity on…
![](https://images.forcetalks.com/wp-content/uploads/2022/01/04132651/sa_1641302759banner3-1024x535.jpg)
Salesforce Field Service Lightning Mobile Extension Toolkit (Beta)
For any field service organization to be successful, it is important to give ample attention to the management. Managing the field forces and service technicians…
![salesforce environments](https://images.forcetalks.com/wp-content/uploads/2020/04/24103136/salesforce-environments.jpg)
Digging Deeper Into Salesforce Environments!
As the Forcedotcom terminology goes, Environments and organizations are equivalent to one another. This article will be focusing on Salesforce Environments, their types, uses, characteristics,…
Popular Salesforce Videos
Salesforce Einstein Prediction Builder and Einstein Next Best Action
Salaesforce Einstein Prediction Builder is a declarative tool that helps fast-track predictions based on Salesforce fields. This will help a Salesforce admin to custom-build predictions…
Salesforce Integration with Heroku
You can integrate Heroku and the Salesforce Platform in several ways, and choosing among them comes down to understanding your requirements and the capabilities of…
Build Smarter Apps with Einstein Object Detection
Einstein Object Detection allows you to easily integrate advanced computer vision technology into your Salesforce workflows and external applications. Join us and learn how to…
Popular Salesforce Infographics
![Salesforce portal](https://images.forcetalks.com/wp-content/uploads/2023/05/08061449/sa_1683526473education%20portal.png)
All the Ways Salesforce Portal for Education Can Help Logistically
The education industry is layered and has multiple logistical elements in its workflow. How would we do it if we were to improve it? The…
![Right Salesforce Partner](https://images.forcetalks.com/wp-content/uploads/2021/02/18071658/Right-Salesforce-Partner-1.png)
Choosing the Right Salesforce Partner - Guide
Tips To Hire The Right Salesforce Partner for Growth & Success Salesforce is compact with some of the most exemplary features like no other CRM…
![data cleaning](https://images.forcetalks.com/wp-content/uploads/2018/01/20131550/data-cleaning.png)
How Salesforce Admins Manage their Data?
No matter how long you’ve been working within Salesforce, it’s important to regularly evaluate the data management systems you have in place and review the…