• Steve Cairney NOW
  • NEWBIE
  • 30 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 8
    Replies
Hi, I'm trying to fill out lookup relationship field on one object using the name (auto number) of another.

I've tried process builder but I don't think it's possible so I'm thinking a trigger is whats needed.

Example,

The main object is called Patient__c has each record will have a name such as PAT-1234
The second object is called Prescription__c and using API (not my department) and that has lookup field for Patient__c and a field called SFPatientREF__c which is filled in PAT-1234. This is done on insert with the API

To connect the two, I need to popute the look up field with the ID of PAT-1234 so would it be possible to pull this into a feild called SFPatientID__c and have process builder to the rest?
Hi all, I have trigger but I'm stuggling to write the test class (I still don't have the experience to do this on my own yet!) Could anyone point me in the right direction please?
 
trigger DoctorTicket on Zendesk__Zendesk_Ticket__c (before insert, before update){
    Zendesk__Zendesk_Ticket__c ticket = trigger.new[0];
    String opname = ticket.Doctor_Name__c;

    // if there's a value populated, get the ID of the record to be related and update the lookup field
    if(opname != null && opname != ''){
        Doctor__c o = [SELECT Id FROM Doctor__c where Name=:opname LIMIT 1]; //query SFDC for a record

        // if an object was returned and that object is different from the current object, update the field
        if(o.ID != null){
            if(o.ID != ticket.Doctor__c){
                ticket.Doctor__c = o.Id;
            }
        }
    }
}

 
Hi, I'm spitballing here, but if I had a couple of PICKLIST's that contained the terms

Excellent
Average
Poor

and these where assigned a value is true in an IF statement (3,2,1) would it be possible to get a total to give a final score?

Example:
IF(ISPICKVAL( picklist__c, "Excellent"), 3,0,
IF(ISPICKVAL( picklist__c, "Average"), 2,0,
IF(ISPICKVAL( picklist__c, "Poor"), 1,0,
0
)))

Can I add another picklist__c in the same formula and add up the results?
Hi all, I have trigger but I'm stuggling to write the test class (I still don't have the experience to do this on my own yet!) Could anyone point me in the right direction please?
 
trigger DoctorTicket on Zendesk__Zendesk_Ticket__c (before insert, before update){
    Zendesk__Zendesk_Ticket__c ticket = trigger.new[0];
    String opname = ticket.Doctor_Name__c;

    // if there's a value populated, get the ID of the record to be related and update the lookup field
    if(opname != null && opname != ''){
        Doctor__c o = [SELECT Id FROM Doctor__c where Name=:opname LIMIT 1]; //query SFDC for a record

        // if an object was returned and that object is different from the current object, update the field
        if(o.ID != null){
            if(o.ID != ticket.Doctor__c){
                ticket.Doctor__c = o.Id;
            }
        }
    }
}

 
Hi, I'm spitballing here, but if I had a couple of PICKLIST's that contained the terms

Excellent
Average
Poor

and these where assigned a value is true in an IF statement (3,2,1) would it be possible to get a total to give a final score?

Example:
IF(ISPICKVAL( picklist__c, "Excellent"), 3,0,
IF(ISPICKVAL( picklist__c, "Average"), 2,0,
IF(ISPICKVAL( picklist__c, "Poor"), 1,0,
0
)))

Can I add another picklist__c in the same formula and add up the results?