1 2 Previous Next 19 Replies Latest reply on Feb 6, 2020 4:48 PM by Paul Donders

    Mapping Requested By to Caller Name

    John Wisdom
      Share This:

      Because our users can create tickets and requests in self service on behalf of other people (which is great!) we would really like to be able to populate the Caller Name field on Incidents and Service Requests with the Requested By value. This will allow the requester to get the emails on close and modification, etc.. As is the staff user assigned to the ticket needs to remember to check the Incident History, when something has been submitted via self service, and manually populate the Caller Name field if it is different that the Client Name.

       

      Has anyone found a way to do this?

       

      Thank you

        • 1. Re: Mapping Requested By to Caller Name
          Paul Donders

          Hi John,

           

          In this scenario the requested by is actually the “createdby”. You can use this in emails as well, like when createdby is client send email.

           

          Hope this helps

           

          Paul Donders

          InfraVision

          • 2. Re: Mapping Requested By to Caller Name
            John Wisdom

            Hi Paul

             

            Yes, I understand. But we use Caller Name on our Incidents and Service Requests and that attribute has value for us in views and reports as well as email alerts. I can create a workflow rule to fire on the desired condition:

             

            (TEXT(BMCServiceDesk__contactType__c) = "Self Service") && CreatedById <> BMCServiceDesk__FKClient__c

             

            but I can not populate Caller Name with another field value on the Field Update. It requires a specific user name:

             

            Thanks

            • 3. Re: Mapping Requested By to Caller Name
              Paul Donders

              Hi John,

               

              Ok I see. A simple apex trigger can do the job, but believe process builder as well. Here you can update caller name with a reference field.

               

              At the moment I’m not behind a pc, so not able to check if my above statement is 100% correct. I can check tomorrow

               

              Paul Donders

              InfraVision

              • 4. Re: Mapping Requested By to Caller Name
                John Wisdom

                No worries. Thanks.

                 

                But, for future reference, I never use the words "simple" and "Apex" in the same sentence.

                 

                Thanks again.

                • 5. Re: Mapping Requested By to Caller Name
                  Paul Donders

                  Spot on John.

                   

                  Sorry, in future I will use my words carefully, but as you know happy to help whenever I can!

                   

                  Paul Donders

                  InfraVision

                  • 6. Re: Mapping Requested By to Caller Name
                    Paul Donders

                    Hi John,

                     

                    here is your solution. Please try in sandbox. In my test I name the field Caller_Name__c, bold in code as well.

                     

                    On Incident create a new trigger:

                     

                    /**

                    * Trigger Name: IV_RF_Incident_Trigger

                    * @author: Paul Donders

                    * Date: 15-12-2017

                    * Requirement/Project Name: Remedyforce

                    * @description: xxxxxxxx

                    */

                    trigger IV_RF_Incident_Trigger on BMCServiceDesk__Incident__c (before insert, after insert, before update, after update, before delete, after delete) {

                     

                        IV_RF_Incident_TriggerClass.IVCallername(Trigger.old, Trigger.new);

                     

                    }

                    //End of trigger

                     

                     

                     

                     

                    This trigger will call the following apex class. (Please insert this first under Apex Class)

                     

                     

                    public class IV_RF_Incident_TriggerClass {

                     

                        public static void IVCallername (List<BMCServiceDesk__Incident__c>      

                        oldIncidents,List<BMCServiceDesk__Incident__c> newIncidents) {

                        /**

                         * @description: This trigger will copy the value of the CreatedBy to the Callername field

                         *             

                         * @param oldIncidents Trigger.old

                         * @param newIncidents Trigger.new

                         */

                     

                           string oldcreatedby;

                          

                           // Initialize some variables if it's an Insert

                           if  (Trigger.isInsert) {

                              oldcreatedby = null;

                           }

                          

                     

                            if (Trigger.isBefore) {

                                if (Trigger.isInsert || Trigger.isUpdate) {

                                      

                                    // Walk through all records  

                                    for(Integer i=0;i<newIncidents.size();i++)

                                    {

                     

                                        // When it's a update, fill the variable with the old values to compare

                                        if  (Trigger.isUpdate) {

                                          oldcreatedby = oldIncidents[i].createdbyid;

                                        }

                                       

                                        if((oldcreatedby != newIncidents[i].BMCServiceDesk__FKClient__c) && (newIncidents[i].createdbyId != newIncidents[i].BMCServiceDesk__FKClient__c) && (newIncidents[i].BMCServiceDesk__contactType__c == 'Self Service')){

                                                   

                                            // Walk through the list and set the correct name       

                     

                                                   newIncidents[i].Caller_Name__c = newIncidents[i].createdbyid;

                                           

                                           

                                        }

                                    }

                     

                                }

                            }  

                     

                        } // end IVCallername

                     

                     

                     

                    } // end Class IV_RF_Incident_TriggerClass

                    2 of 2 people found this helpful
                    • 7. Re: Mapping Requested By to Caller Name
                      kedar zavar

                      Jon,

                       

                      We (on multiple projects) use different approach - additional field called as “cc” meaning share or copy all emails. Simple user look up. End user can pick a person then you can use this to share records or send emails.

                       

                      Works great.

                       

                      Cc is someone like to be copied on all this for all updates etc.

                       

                      We have also gone step further to share this on self service so they CC can track it.

                       

                      I will post complete solution however just another extra field could help to simply this.

                      Kedar

                      2 of 2 people found this helpful
                      • 8. Re: Mapping Requested By to Caller Name
                        John Wisdom

                        Hi Paul

                         

                        Thanks for the Apex solution. It is what I would lean towards if there is no way that BMC could develop a way to capture the "Requested By" value on service request. It seems such a waste to have a perfectly good value that we can't use.

                         

                         

                        One question on your Apex voodoo; It does not appear to take in account when 'created by' and 'client' are one and the same. Is that true?  We only want to populate Caller when it is different than client.

                         

                        Thanks again.

                        1 of 1 people found this helpful
                        • 9. Re: Mapping Requested By to Caller Name
                          John Wisdom

                          Hello Kedar

                           

                          Thank you but I do not want to create a custom field to solve this.  I appreciate your input though.

                          • 10. Re: Mapping Requested By to Caller Name
                            Jennifer Schertz

                            Awesome!  Thanks so much for sharing this Paul Donders.  Let me know if this works for you John Wisdom.

                            • 11. Re: Mapping Requested By to Caller Name
                              Paul Donders

                              Hi John Wisdom

                               

                              It does. It check source = self service and CreatedBy not equal to Client.. The "!=" basically means Not Equal..

                               

                              if((oldcreatedby != newIncidents[i].BMCServiceDesk__FKClient__c) && (newIncidents[i].createdbyId != newIncidents[i].BMCServiceDesk__FKClient__c) && (newIncidents[i].BMCServiceDesk__contactType__c == 'Self Service')){

                               

                              I get your point completely. Certain things should be standard, and be included in the product. Sorry, it's not (yet) the case. Therefor we have to create a bunch of extra logic. Within our company we created a so called "Best Practise" package, that includes many items.

                              2 of 2 people found this helpful
                              • 12. Re: Mapping Requested By to Caller Name
                                John Wisdom

                                Good deal. Yep, I see that now.  Thanks!

                                • 13. Re: Mapping Requested By to Caller Name
                                  John Wisdom

                                  I replaced Caller_Name__c with FKUser1__c and have it set up in a sandbox. Works great!

                                  Thanks, Paul. Perfecto!

                                  • 14. Re: Mapping Requested By to Caller Name
                                    Paul Donders

                                    Perfect.

                                     

                                    Glad I could help.

                                     

                                    Ps be aware that a test class is needed to push all to production when you are ready.

                                     

                                    The test class basically creates a new incident with source self service and createdby and client set ti different uses. On top make sure that all your required fields are set as well.

                                     

                                    Please let me know when you are stuck.

                                     

                                     

                                     

                                    Paul Donders

                                    InfraVision

                                    1 2 Previous Next