• Debanjan Sharma
  • NEWBIE
  • 40 Points
  • Member since 2016
  • Consultant
  • Deloitte Digital


  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 0
    Questions
  • 7
    Replies
Hi! I'm stuck on a bit of code that I hope someone might be able to help me with. Here's the problem I'm trying to solve:
 
I want to fill in 3 lookup fields on my custom object called "Approver 1", "Approver 2", "Approver 3". These custom fields are a lookup to the user record. I've created a custom metadata definition to store the mapping of owner of the record, to these approvers. Since custom metadata does not support entity definitions to the user record, I used a text field to store the owner Full name, Approver 1 full name, etc.
 
I've created a trigger and trigger handler to fill in these fields whenever a record is created. I'm stuck though in figuring out how to match up my custom metadata with the records being inserted. Essentially, for every record that is being inserted I want to see if there is a reference to the owner name in my custom metadata. If there is a match, I want the approver 1 lookup field on my custom object to be filled with the user that corresponds to the full name I put in my custom metadata. Here's what I have so far.


User-added image
 
I've attached a screenshot, and here's the gist: https://gist.github.com/Sunnydalelow/87cd1d66e1ac1c68f8f15f3390309749#file-gistfile1-txt

Here's a sample of one of my custom metadata records:
User-added image
I'm using rest api to create a note, it goes like this:
 {
    "Title":"note title ",
    "ParentId":"00Q46000004UQ9YEAW",
    "Body":"note body bhugvyf"
}

The parent is a Lead, but that note wont show on the Notes of that lead. The only notes that appear are the ones directly created on the browser.
Any idea on how to address this issue? 
Thanks
I am trying to alter the code provided by Service Rocket. We need the trigger to fire when the approval process tied to Custom_Dev__C is approved. I have little experience with writing Apex or any code. I understand that it’s creating the Jira issue when a new case is created.
 
  1. Compare in Trigger and have this in IF Condition whether [Approved__c == True]
    1. Approved__c is a checkbox that is subject to a field update after going through the approval process.
Could someone please help me make the necessary changes to get this working? Or explain where to insert the code to make it work.
trigger CreateIssue on Custom_Dev__C (before insert) {
// Check whether current user is not JIRA agent so that we don't create an infinite loop.
  if (JIRA.currentUserIsNotJiraAgent()) {
    for (Custom_Dev__C c : Trigger.new) {
      // Define parameters to be used in calling Apex Class
      String objectType =  ‘Custom_Dev__C’; // Please change this according to the object type
      String objectId = c.id;
      String projectKey = 'CustomDev'; //Please change this according to the JIRA project key
      String issueType = '10';   //Please change this according to the JIRA issue type ID
      // Calls the actual callout to create the JIRA issue.
      JIRAConnectorWebserviceCalloutCreate.createIssue(JIRA.baseUrl, JIRA.systemId, objectType, objectId, projectKey, issueType);
    }
  }
   
}
 
 

I am using the following APEX trigger to add Contacts automatically to cases that want to be (theres a check box for it) but it is not adding case team members to case. What am I missing here?

trigger CaseTeamAddition on Case (after insert) {
 
if (Trigger.isAfter){
                If (Trigger.isInsert){
                                CaseTeamRole caseTeamRole = [SELECT Id 
FROM CaseTeamRole 
WHERE Name = 'Case Update Team'
LIMIT 1];
 
                                List<Id> accountIdList = new List<Id>();
                                
                                For (Case currentCase : Trigger.new){
                                                accountIdList.add(currentCase.AccountId);
                                }
                                
                                List<Contact> contactList = [SELECT Id, AccountId
                                                                                    FROM Contact
                                                                                    WHERE AccountId IN : accountIdList
                                                                                   AND Get_Email_Updates__c = true];
                                
                                List<CaseTeamMember> caseMembersToInsert = new List<CaseTeamMember>();
                                For (Case currentCase : Trigger.new){
                                               
                                                For (Contact currentContact : contactList){
                                                                If (currentContact.AccountId == currentCase.AccountId){
                                                                               
                                                                                CaseTeamMember newMember = new CaseTeamMember(ParentId = currentCase.Id,
                                                                                                                                                                                                MemberId = currentContact.Id,
                                                                                                                                                                                                TeamRoleId = caseTeamRole.Id);
                                                                                caseMembersToInsert.add(newMember);
                                                                }
                                                }
                                }
 
                                if (caseMembersToInsert.size() > 0){
                                                insert caseMembersToInsert;
                                }
                                                               
                                }
}                               
    }

Hi! I'm stuck on a bit of code that I hope someone might be able to help me with. Here's the problem I'm trying to solve:
 
I want to fill in 3 lookup fields on my custom object called "Approver 1", "Approver 2", "Approver 3". These custom fields are a lookup to the user record. I've created a custom metadata definition to store the mapping of owner of the record, to these approvers. Since custom metadata does not support entity definitions to the user record, I used a text field to store the owner Full name, Approver 1 full name, etc.
 
I've created a trigger and trigger handler to fill in these fields whenever a record is created. I'm stuck though in figuring out how to match up my custom metadata with the records being inserted. Essentially, for every record that is being inserted I want to see if there is a reference to the owner name in my custom metadata. If there is a match, I want the approver 1 lookup field on my custom object to be filled with the user that corresponds to the full name I put in my custom metadata. Here's what I have so far.


User-added image
 
I've attached a screenshot, and here's the gist: https://gist.github.com/Sunnydalelow/87cd1d66e1ac1c68f8f15f3390309749#file-gistfile1-txt

Here's a sample of one of my custom metadata records:
User-added image
Hi,
Can someone please tell me the object name where all the sharing rules are getting stored.
Thanks in advance.

Regards,
Mohd Imran
Best Practice : When someone takes the time/effort to repspond to your question, you should take the time/effort to either mark the question as "Solved", or post a Follow-Up with addtional information.

User-added image


      That way people with a similar question can find the Solution without having to re-post the same question again and again. And the people who reply to your post know that the issue has been resolved and they can stop working on it. 

Thanks #Copy_Steve Molis