• #28613
    Forcetalks

    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:

    1. Create Account if Brokerage !=null
    2. Create another account if Manage Brokerage != null and set parentId = Brokerage account id (created in 1 point)
    3. Create new contact record and set accountId = Manage Brokerage account id (created in 2 point)
    4. create new field condidate__c(lookup) on contact and fill it with Condidate__c record id
    5. 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);
    }
    }
    }
    

    Tagged: , ,

Viewing 1 post (of 1 total)

Please to reply to this topic.

CONTACT US

We're not around right now. But you can send us an email and we'll get back to you, asap.

Sending

About Us

Forcetalks is a Salesforce collaboration platform for coders & developers, geeks & nerds, consultants & business heads, admins & architects, managers & marketers and of course the business owners. A community where you can learn from, where you can contribute to. For you. For Salesforce. Read More...

Copyright 2018 Forcetalks. All Right Reserved.

Log in with your credentials

or    

Forgot your details?