• Cris T.
  • NEWBIE
  • 94 Points
  • Member since 2019
  • Admin

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 24
    Questions
  • 42
    Replies
Hi, can someone guide me how can i cover atleast 75 of this class?
 
public class WorkOrderRelatedList{
    
    public SVMXC__Service_Order_Line__c[] WorkDetailList{get;set;}
    String u = UserInfo.getUserId();
    public WorkOrderRelatedList(ApexPages.standardController std){
        WorkDetailList=new SVMXC__Service_Order_Line__c[]{};
         string WorkOrderId=ApexPages.currentPage().getParameters().get('id');
        if(WorkOrderId==NULL){
            system.debug('No Id available');
        }
        else{
            SVMXC__Service_Order__c[] AccWL=new SVMXC__Service_Order__c[]{};
            AccWL=[Select id,  (select ID, Name, lastmodifieddate, SVMXC__Line_Type__c,SVMXC__Product__c, SVMX_PS_Consumed_Qty__c, SIG_SC_Description__c, SVMXC__Group_Member__c, 
                                       SVMX_PS_Customer_Start_Date__c, SVMX_PS_Customer_Start_Time__c, SVMX_PS_Customer_End_Time__c, SVMX_PS_Customer_End_Date__c, SIG_Duration_Hours__c
                                from SVMXC__Service_Order_Line__r where (SVMXC__Line_Type__c = 'Labor' AND  CreatedById =:  u) OR (SVMXC__Line_Type__c = 'Travel' AND  CreatedById =:  u ) OR SVMXC__Line_Type__c = 'Parts' )  
                  from SVMXC__Service_Order__c where id =:WorkOrderId];
            for( SVMXC__Service_Order__c c:AccWL ){
                for(SVMXC__Service_Order_Line__c obj:c.SVMXC__Service_Order_Line__r ){
                    WorkDetailList.add(obj);
                }
            }
        }
    }
}



I only covered 45%...

 

@isTest
class WorkOrderRelatedList_UT{

    @isTest
    static void testtMethod() 
    { 
          String u = UserInfo.getUserId();
          SVMXC__Service_Order__c woTest = new SVMXC__Service_Order__c();
          woTest.SVMXC__Priority__c = 'Normal';
          insert woTest;
          
          SVMXC__Service_Order__c wo = [Select ID from SVMXC__Service_Order__c where Id =: woTest.id];
         
        
         ApexPages.StandardController sc = new ApexPages.StandardController(woTest);
         WorkOrderRelatedList testWo     = new WorkOrderRelatedList(sc);
        
         PageReference pageRef = Page.WorkDetailRelatedList; // Add your VF page Name here
         pageRef.getParameters().put('id', String.valueOf(wo.Id));
         Test.setCurrentPage(pageRef);
         
         SVMXC__Service_Order_Line__c workDetail = new SVMXC__Service_Order_Line__c();
         workDetail.SVMXC__Service_Order__c = wo.Id;
         workDetail.RecordTypeId = '0121i000000Gs2VAAS';
         workDetail.SVMXC__Line_Type__c = 'Labor';
         
         insert workDetail;
        
        
    }
}


My visualforce page:

 

<apex:page standardController="SVMXC__Service_Order__c" extensions="WorkOrderRelatedList" tabStyle="SVMXC__Service_Order_Line__c" lightningStylesheets="true">
<style>
body .bPageBlock .pbBody .labelCol{
     float:left;
}
</style>
    
    <apex:pageBlock Title="My Work Details">
        
            <apex:pageBlockTable style="width:100%" value="{!WorkDetailList}" var="n" >
                <apex:column style="width:50px" headerValue="Line Number" value="{!n.Name}"/>
                <apex:column style="width:50px" headerValue="Line Type" value="{!n.SVMXC__Line_Type__c}" />
                <apex:column style="width:10px" headerValue="Part" value="{!n.SVMXC__Product__c}" />
                <apex:column style="width:1px" headerValue="Consumed Qty" value="{!n.SVMX_PS_Consumed_Qty__c}" />
                <apex:column style="width:10px" headerValue="SC Description" value="{!n.SIG_SC_Description__c}" />
                <apex:column style="width:10px" headerValue="Technician" value="{!n.SVMXC__Group_Member__c}" />
                <apex:column style="width:10px" headerValue="Reported Start Date" value="{!n.SVMX_PS_Customer_Start_Date__c}" />
                <apex:column style="width:10px" headerValue="Reported Start Time" value="{!n.SVMX_PS_Customer_Start_Time__c}" />
                <apex:column style="width:10px" headerValue="Reported End Date" value="{!n.SVMX_PS_Customer_End_Date__c}" />
                <apex:column style="width:10px" headerValue="Reported End Time" value="{!n.SVMX_PS_Customer_End_Time__c}" />
                <apex:column style="width:10px" headerValue="Duration(hours)" value="{!n.SIG_Duration_Hours__c}" />


           
   </apex:pageBlockTable>
        
        
    </apex:pageBlock>    
    
</apex:page>

​​​​​​​
  • September 22, 2020
  • Like
  • 0

We have an installed app integrated with Salesforce and we can generate PDF's with this app using HTML & CSS.

Now the problem is that my header keeps repeating on all pages which doesn't look nice and professional. Any ideas how can I keep my header to be only on the first page and not others?

 

  • September 12, 2020
  • Like
  • 0

Hi all,

I have the following error:

Error:Apex trigger countWL caused an unexpected exception, contact your administrator: countWL: execution of BeforeUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id a1g1X000002QxttQAC; first error: SELF_REFERENCE_FROM_TRIGGER, Object (id = a1g1X000002Qxtt) is currently in trigger countWL, therefore it cannot recursively update itself: []: Trigger.countWL: line 11, column 1


This is my trigger:

trigger countWL on SVMXC__Parts_Request_Line__c (before update, before insert) {


     //take all the parts line with their parts work detail
     List<SVMXC__Parts_Request_Line__c> partsWithWL = [SELECT Id,Name,(SELECT Id,Name FROM Work_Details__r WHERE SVMXC__Line_Type__c= 'Parts') FROM SVMXC__Parts_Request_Line__c WHERE Id IN :Trigger.New];
     System.debug('partsWithWL '+partsWithWL);
     
    
     for(SVMXC__Parts_Request_Line__c loopParts : partsWithWL ){
         loopParts.CountWLParts__c = loopParts.Work_Details__r.size();
         update loopParts;
         System.debug('loopParts.CountWLParts__c' + ' '+loopParts.CountWLParts__c);
        
     }
   
   
}

What I am doing wrong here? Why the trigger fails?​​​​​​​
Hi, I have this trigger which checks if I have a duplication(Dispatcher) in each Service Team.
trigger AvoidduplicateDispatcher on SVMXC__Dispatcher_Access__c (before insert) {

// for every new dispatcher created fetches the id of the service team selected in serviceTeamMap
    map<Id, Set<String>> serviceTeamMap = new map<Id, Set<string>>();
    for(SVMXC__Dispatcher_Access__c disp: trigger.new){
        if(disp.SVMXC__Service_Team__c!= null){
            serviceTeamMap.put(disp.SVMXC__Service_Team__c, new set<String>());
            system.debug('************'+serviceTeamMap);
        }
     }
     

    if(!serviceTeamMap.isEmpty()){
        for(SVMXC__Dispatcher_Access__c disp1: [Select Id, SVMXC__Dispatcher__c, SVMXC__Service_Team__c from SVMXC__Dispatcher_Access__c where SVMXC__Service_Team__c =: serviceTeamMap.keySet()]){
            serviceTeamMap.get(disp1.SVMXC__Service_Team__c).add(disp1.SVMXC__Dispatcher__c);
        }
        system.debug('******serviceTeamMap*****'+serviceTeamMap);
    }
    
    if(!serviceTeamMap.isEmpty()){
        for(SVMXC__Dispatcher_Access__c dispRec: trigger.new){
            system.debug('************'+dispRec.SVMXC__Dispatcher__c);
             Set<String> dispSet = serviceTeamMap.get(dispRec.SVMXC__Service_Team__c);
             system.debug('************dispSet '+dispSet);
             if(dispSet.contains(dispRec.SVMXC__Dispatcher__c)){
                 system.debug('************'+dispRec.SVMXC__Dispatcher__c);
                     dispRec.addError('You are already a dispatcher in this Service Team!');
             }  
             
        }
    }

}


This is my Test Class.

@isTest
public class AvoidduplicateDispatcher_UT {
    @isTest static void AvoiDuplicateDispatcher_TestMethod(){
        SVMXC__Dispatcher_Access__c dp = new SVMXC__Dispatcher_Access__c();
        dp.SVMXC__Dispatcher__c = '0051i0000012ogr';
        dp.SVMXC__Service_Team__c = 'a341i000000PBPY';
        insert dp;
        
        SVMXC__Dispatcher_Access__c dp1 = new SVMXC__Dispatcher_Access__c();
        dp1.SVMXC__Dispatcher__c = '0051i0000012ogr';
        dp1.SVMXC__Service_Team__c = 'a341i000000PBPY';
        Database.SaveResult sresult = Database.insert(dp1, false); 
    }
}


I have 100% coverage.

 

However in PROD when i want to migrate I have this error:

 

System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, You are already a dispatcher in this Service Team!: []
Stack Trace: Class.AvoidduplicateDispatcher_UT.AvoiDuplicateDispatcher_TestMethod: line 12, column 1

How can i fix this guys?​​​​​​​

Hi, I have two objects.

Dispatcher(SVMXC__Dispatcher_Access__c) and Service Team(SVMXC__Service_Group__c).

The relationship between Dispatcher and the Service Team is many to one, in other words there can be multiple dispatchers associated to one Service Team. 

Here is a picture to make you understand:For example, we have this team AP-S-Indonesia FSE and we have 6 dispatchers related to this Service Team.
User-added image

I want to create a trigger to fetch all the Dispatchers related to this Service Team. Any suggestions?

Hi, we have 1 field which is Date/Time. The problem is that this field will get converted according to the user timezone. We have people working from all over the world and we don't want time conversion. We want if we select 7/6/2020 11:00 AM to be the same for everybody not to be converted on the current user timezone... is there a solution for this? I never worked with UTC timezone...

Hi! I have created a trigger:

trigger SIG_permissionToEditAdminTasks on SIG_Administrative_Task__c (before update) {
       

         SVMXC__Service_Order__c queueOwner = new SVMXC__Service_Order__c();
        ApexPages.StandardController sc = new ApexPages.StandardController(queueOwner);
       SIG_QueueOwnerUpdate classQueue = new SIG_QueueOwnerUpdate(sc);
         
         
         
          public Set<String> memberIds = new Set<String>();
          String currentUserID = UserInfo.getUserId();
          SIG_Administrative_Task__c admTask = new SIG_Administrative_Task__c();
          
          
     
      //fetch the id of the creator of the record <start>
           Set<String> ownerIds = new Set<String>();
        for (SIG_Administrative_Task__c record : Trigger.New) {
            ownerIds.add(record.OwnerId);
             
        }
        
      // <end>
        
        List<Group> groups = [SELECT Id, (SELECT Id, UserOrGroupId FROM GroupMembers) FROM Group WHERE Id =: ownerIds];
        System.debug('####groups' + groups);    
        
          
         Set<String> memberIdsByGroupId = new Set <String>();
   
        //fetch the id's of the users from the the current owner queue  <start>
        for (Group groupRec : groups) {
         
            for (GroupMember member : groupRec.GroupMembers) {
                memberIds.add(member.UserOrGroupId);
            }
              
        }
        // <end>
       system.debug('memberIds123'+memberIds);

         for (SIG_Administrative_Task__c record : Trigger.New) {
            if((memberIds.contains(currentUserID) || record.createdById == UserInfo.getUserId() || record.OwnerID == UserInfo.getUserId() ))
            {
           
            }
            else
            {
               record.addError('You need to be the owner or to be inside of a queue to edit an Admin Task');
            }
        }
    

}

On this line I am trying to call a class in my trigger:

ApexPages.StandardController sc = new ApexPages.StandardController(queueOwner);
 SIG_QueueOwnerUpdate classQueue = new SIG_QueueOwnerUpdate(sc);


Everything looks fine.. but when I try to activate my trigger and do an update on a record i have this error:

User-added imageWhen i took a look in my class, line 73 this is what I see:

User-added imageHow can I call my class without getting this error?

Hello, I want to update my attachments name after they are created. This works but the name of the Work Order(custom object) is not automatically. User-added imageThis is my attachments and you can see Related to : WO-0003061.

my trigger, it works if i hard code the name:

 

trigger SetTitleToAttachment on Attachment (before insert) { 


        for(Attachment a: Trigger.new){
          
            if(a.Name.startsWith('SIG_PM_Work_Order_Service_Report')){
                a.Name = 'Work Order name dynamically ';
            } else if (a.Name.startsWith('SIG_HandoverCheckList_Customer_To_SIG_Report')){
                a.Name = 'ServiceReport.pdf';
            }
            
        }


}


I want to on the line  a.Name = 'Work Order name dynamically '; to be instead of this string to be the name WO-0003061. How can i do this?

Please help. I would appreciate a lot :)

Hi, we have installed a managed package in Salesforce and it is basically an app and when we enter on that app the link changes.. is there a way to get url from that app?

 

User-added image

I want to get this url:https://sig-cb--full--svmxc.cs88.visual.force.com/apex/SVMXC__OPDOC_Delivery?SVMX_recordId=a391i000000CjVdAAK&SVMX_processId=SIG_PM_Work_Order_Service_Report&SVMX_retURL=/a391i000000CjVdAAK

 

Is that possible?

Hello,

I have a small trigger:
 

trigger SetTitleToAttachment on Attachment (after insert) { 

    
    //store the ID of the new attachment
    ID attachment;
    ID workOrder;

    
    
    for (Attachment att : Trigger.new) {
        attachment = att.ID;
        workOrder = att.ParentId;
       
        
    }
   Map<ID, SVMXC__Service_Order__c> wo =new Map<ID, SVMXC__Service_Order__c>( [SELECT ID, NAME, SVMX_PS_Ship_To_Name__c from SVMXC__Service_Order__c WHERE ID =: workOrder ]);


}


My question is: how can I access the fieds: Name and SVMX_PS_Ship_To_Name__c from this map?

I'm confused. 

Hello, I have a requirement to create a trigger to not allow users to edit records if they are not the creator OR if they are not the owner. Owner can be a simple user or a QUEUE.
 

This is what I wrote until now... my code is not working.

 

trigger permissionToEditAdminTasks on SIG_Administrative_Task__c (after update) {
  
      //fetch the id of the creator of the record <start>
           Set<String> ownerIds = new Set<String>();
        for (SIG_Administrative_Task__c record : Trigger.New) {
            ownerIds.add(record.OwnerId);
             
        }
        
       
        
      // <end>
        
        List<Group> groups = [SELECT Id, (SELECT Id, UserOrGroupId FROM GroupMembers) FROM Group WHERE Id =: ownerIds];
        System.debug('####groups' + groups);    
        
          
        Map<String, Set<String>> memberIdsByGroupId = new Map<String, Set<String>>();
        
        //fetch the id's of the users from the the current owner queue  <start>
        for (Group groupRec : groups) {
            Set<String> memberIds = new Set<String>();
            for (GroupMember member : groupRec.GroupMembers) {
                memberIds.add(member.UserOrGroupId);
            }
               System.debug('####memberIds  ' + memberIds );   
        }
        // <end>
       

        for (SIG_Administrative_Task__c record : Trigger.New) {
            if (memberIdsByGroupId.get(record.OwnerId) != null && memberIdsByGroupId.get(record.OwnerId).contains(UserInfo.getUserId()))
            {
             
            }else{
                 record.addError('You have not permission for editing this record');
                  System.debug('record.OwnerId' + record.OwnerId);
            }
        }
    

}
I cannot edit the record no matter what, I don't know what is wrong in my code.. please help.
Hi! I want to create a class that will fetch the ID of an Account dynamic when I create a new record. We have a custom object named Account Change request. This object can be found in the related lists from Account. When user press to create a new Account Change Request I want to override it with my visualforce page, thus I would need to display the informations on my VF page from that Account. I tried to create by myself but it's not working..
 
public class MasterDataChange{


 public Account parentAccount{get; set;}
 public Account_Change_Request__c accChangeRequest;


 public MasterDataChange(ApexPages.StandardController controller){
    
  String parentAccId = ApexPages.currentPage().getParameters().get('id');
     if(parentAccId != null){
            parentAccount= [SELECT Id, Name FROM Account WHERE Id = :parentAccId limit 1];
                accChangeRequest.Account__c = parentAccount.Id;
            }
         
        } 

  
 public PageReference save(){
   insert accountChangeRequest;
   
    PageReference pg = new PageReference('/'+parentAccount.Id);
          pg.setRedirect(true);
         return pg;
 }
}

Account__c is my master-detail with the Account object.. please help.
Hello, we want to migrate every button from classic to lightning and I'm stuck with this particular button. In classic it works fine but when I switch to Lightning its not working. Simply just remain in the stage of 'Loading...' and the page remains blank.. 

This is how my button and VF page looks:

User-added imageUser-added image
 
<apex:page standardController="Account" lightningStylesheets="true">
    <c:QV_Jump QVURL="https://delinvmas624/QvAJAXZfc/opendoc.htm?document=CRM/CRM_Price_Waterfall.qvw&host=delinvmas624&select=CRM_ACCOUNT,{!Account.SAP_Customer_ID__c}&select=CRM_ACCOUNT_2,{!Account.SAP_Customer_ID__c}"
               QVURL_mobile="https://delin-qv-mobile-idp-prod.sig.dom/QvAJAXZfc/opendoc.htm?document=CRM/CRM_Price_Waterfall.qvw&host=delinvmas369&select=CRM_ACCOUNT,{!Account.SAP_Customer_ID__c}&select=CRM_ACCOUNT_2,{!Account.SAP_Customer_ID__c}" />
</apex:page>
Anyone has an idea why it's not loading in Lightning?
 

Hello, I wrote a trigger to check if the url = 'https://sig-cb--Full.cs88.my.salesforce.com' and the profile of the current user is a specific profile (SIG-FSM-Super User) and if so the trigger shows an error message and also an image which I included in the addError function, it looks like this:

trigger ContactCreationForServiceMaxUsers on Contact (Before insert) {
   
       String baseURL = String.valueof(URL.getSalesforceBaseUrl());
      
       system.debug('<<baseURL>>' + baseURL);
       Boolean isBaseURL = baseURL.contains('https://sig-cb--Full.cs88.my.salesforce.com');
       System.debug(' >> String.valueof(URL.getSalesforceBaseUrl()) >>'+baseURL ); 
       User currentUser = [SELECT Id, Profile.Name FROM USER WHERE Id =:UserInfo.getUserId()]; 
      
       Contact c = new Contact(); 
      
       System.debug(' >> isBaseURL >>'+isBaseURL ); 
       System.debug(' >> currentUser.Profile.Name>>'+currentUser.Profile.Name ); 
   
     for(Contact c : Trigger.New){ 
          if(isBaseURL == TRUE  && currentUser.Profile.Name == 'SIG-FSM-Super User'){
           c.addError(' <p style="color:red; font-size: 20px;">Service contact creation is only allowed from “Account” tab using the blue button “Create Contact” after selecting a account”</p><img id="theImage" src="https://sig-cb--full--c.cs88.content.force.com/servlet/servlet.FileDownload?file=0159E0000002tNp" width="850px" height="100px" alt="Description of image here"/> ', false); 
          } 
     } 
}


Can anyone help me with how to build the test class for the trigger? At least theoretical.

1. First I need to create a contact
2. I need to create a user with a profile = 'super-user'
3. somehow i need to check the addError function..

Something like this...

Hello, I want to show an image when my trigger activates; I created this code but it's not working. I'm not sure, if it is possible to display an image in the addError function...?

trigger ContactCreationForServiceMaxUsers on Contact (Before insert) {

       String baseURL = String.valueof(URL.getSalesforceBaseUrl());
       String imageURL {get;set;}
       system.debug('<<baseURL>>' + baseURL);
       Boolean isBaseURL = baseURL.contains('https://sig-cb--Full.cs88.my.salesforce.com');
       System.debug(' >> String.valueof(URL.getSalesforceBaseUrl()) >>'+baseURL ); 
       User currentUser = [SELECT Id, Profile.Name FROM USER WHERE Id =:UserInfo.getUserId()]; 
       List< document > documentList=[select Name from document where FolderID='0159E0000002tNp' limit 1];
       if(documentList.size()>0)
      {
          imageURL=imageURL+documentList[0].Name;
      }
       Contact c = new Contact(); 
       System.debug(' >> isBaseURL >>'+isBaseURL ); 
       System.debug(' >> currentUser.Profile.Name>>'+currentUser.Profile.Name ); 
   
     for(Contact c : Trigger.New){ 
          if(isBaseURL == TRUE  && currentUser.Profile.Name == 'SIG-FSM-Super User'){
           c.addError(imageURL + ' ' + 'enter som'); 
          } 
     } 
}

the trigger works and it displays   '  null enter som '. My imageURL seems to be null here...
Hi, anybody can help me why I have an error in my code at line 5
public class ContactController {

    
    Profile PROFILE = [SELECT Id, Name FROM Profile WHERE Id=:userinfo.getProfileId()];
   
    if(Profile.ID == '00e1i000000p80k') {
        u.addError('You are not allowed to create contact from this button');
    }
    Else {
        public PageReference saveNew() {
    
   		 try { 
    	    insert Contact; 
   			 } catch(System.DMLException e) {
       		  ApexPages.addMessages(e);
              return null;
   			 }   

   		 return (new ApexPages.StandardController(new Contact())).edit();        

   		}
    }
  
}

On the line: if(Profile.ID = '001i00000p80k')  I have this error
Expecting '}' but was: 'if'

 
I'm in a little bit of struggle here. Have an error in this class. I tried to debug log this error but I don't understand why only one user is having this problem. For the rest of the users this error does not occur. This is the error:
 
Visualforce Page: /apex/VisitReportPage

caused by: System.NullPointerException: Attempt to de-reference a null object Class.VisitReportPageExtension.setIsFullReport: line 105, column 1 Class.VisitReportPageExtension.: line 65, column 1


This is my class:

 

public with sharing class VisitReportPageExtension {

    public List<SelectOption> PicklistValues { get; set; }
    public List<SelectOption> SecondPicklistValues { get; set; }
    public List<SelectOption> LastPicklistValues { get; set; }
    public Map<String, String> PicklistMap = new Map<String, String>();

    Public List<String> selectedValues { get; set; }
    Public List<String> SecondselectedValues { get; set; }
    public List<String> LastSelectedValues { get; set; }

    public static final String DEFAULT_TASK_STATUS = 'New';
    public static final String DEFAULT_TASK_PRIORITY = 'Normal';

    public static final String EVENT_URL_PARAM = 'EventID';
    public static final String RETURN_URL_PARAM = 'retUrl';
    public static final String RECORD_TYPE_URL_PARAM = 'RecordType';
    public static final String ACCOUNT_URL_PARAM = 'AccountId';
    public static final String OPPORTUNITY_URL_PARAM = 'OpportunityId';

    public static final String MEMO_REPORT_DEVELEOPER_NAME = 'Call_Memo';

    private List<List<String>> contactFields;
    private Map<ID, Contact> contactsCache = new Map<ID, Contact>();
    private Map<ID, User> userCache = new Map<ID, User>();
    private List<Message> messages = new List<Message>();
    private Map<Id, RecordType> mInteractionReportRecordTypes = null;

    private boolean isFullReport = true;
    private String retURLParam = null;

    public Boolean isNew { get; private set; }
    public Boolean showCreateContactPopup { get; set; }

    public List<ActionItemWrapper> actionItems { get; set; }
    public List<CustomerParticipantWrapper> customerParticipants { get; set; }
    public List<CustomerParticipantWrapper> internalParticipants { get; set; }
    public Contact contactHandler { get; set; }

    public Visit_Report__c record { get; set; }

    /**
     * Constructor creates instance of class. Loads Interaction 
     * report and related records.
     * @param  stdCtr Standard controller.
    */
    public VisitReportPageExtension(ApexPages.StandardController stdCtr) {
        customerParticipants = new List<CustomerParticipantWrapper>();
        internalParticipants = new List<CustomerParticipantWrapper>();

        record = (Visit_Report__c) stdCtr.getRecord();
        isNew = (stdCtr.getId() == null);

        mInteractionReportRecordTypes =
                RecordTypeService.getRecordTypesForObject('Visit_Report__c');
        loadParams();

        loadInteractionRecord();
        clearContactHandler();
        closeCreateContactPopup();
        setIsFullReport(record.RecordTypeId);


        selectedValues = new List<String>();
        SecondselectedValues = new List<String>();
        LastSelectedValues = new List<String>();

        PicklistValues = new List<SelectOption>();
        SecondPicklistValues = new List<SelectOption>();
        LastPicklistValues = new List<SelectOption>();
        List<Schema.PicklistEntry> FieldPicklistvalues =
                Visit_Report__c.Innovation_presented_to_customer__c.getDescribe().getPicklistValues();

        for (Schema.PicklistEntry FieldPicklistvaluesfor : FieldPicklistvalues) {
            PicklistValues.add(new SelectOption(FieldPicklistvaluesfor.getValue(),
                    FieldPicklistvaluesfor.getLabel()));
            PicklistMap.put(FieldPicklistvaluesfor.getvalue(),
                    FieldPicklistvaluesfor.getLabel());
        }
    }


    private void loadParams() {
        Map<String, String> mGetParams = ApexPages.currentPage().getParameters();
        record.EventID__c = mGetParams.get(EVENT_URL_PARAM);
        retURLParam = ApexPages.currentPage().getParameters().get(RETURN_URL_PARAM);

        //TODO get rec type 
        if (record.RecordTypeId == null) {
            if (mGetParams.containsKey(RECORD_TYPE_URL_PARAM)) {
                record.RecordTypeId = mGetParams.get(RECORD_TYPE_URL_PARAM);
            }
        }
        if (mGetParams.containsKey(ACCOUNT_URL_PARAM)) {
            record.Account_Name__c = mGetParams.get(ACCOUNT_URL_PARAM);
        }
    }

    private void setIsFullReport(Id recordTypeId) {
        isFullReport = (mInteractionReportRecordTypes.get(recordTypeId).DeveloperName != MEMO_REPORT_DEVELEOPER_NAME);
    }


    public boolean getIsFullReport() {
        return isFullReport;
    }
}

Why this error only occurs for only one user? I don't know why the code breaks. Any suggestions?

Hi, I'm struggling to create a query with some users and see their PermissionSets. Until now I created this:

User-added image1.However I'm not sure to add multiple users to my query, in my query we only have one users 'Cristian-Ovidiu Trif'. How can i do this?
2.I'm not sure why i see that 'X00ex00000180zt_128_09_43_34_1'. That's not a permission set.. I only have one permission set which is called 'Send_emails_on_announcements'. Anybody has idea why?

Hi, I have the following error: I'm not sure how to fix this

 When i ran the class i have one error which is this..
"SendEmail failed. First exception on row 0; first error: INVALID_ID_FIELD, WhatId is not available for sending emails to UserIds.: [whatId, a3D9E000000Mdz0]—Send Email method looks for a contact while sending emails"

This is my code for sending email to users or queues

global class sendEmailBatchClass implements Database.Batchable < sobject > {
   
    global Database.QueryLocator start(Database.BatchableContext bc) {
        Date dt = date.today().addDays(1);
        return Database.getquerylocator([SELECT Id,OwnerId,Name,Owner.Email,
        (Select Id,OwnerId,Name,Owner.Email from SVMXC__Work_Orders__r where SIG_Due_Date__c =:dt and SVMXC__Order_Status__c NOT IN ('Closed','Completed')),
        (Select Id,OwnerId,Name,Owner.Email from Administrative_Tasks__r where SIG_Due_Date__c =:dt and SIG_Status__c Not IN ('Closed','Completed')) 
        From SVMXC__Service_Request__c  WHERE SVMXC__Status__c = 'Open' and SVMX_SIG_Due_Date__c  =: dt]);
    }
    
    global void execute(Database.BatchableContext bc, List <SVMXC__Service_Request__c> scope) {
       
        String userStringVal = '005';
        Map<Id,set<SVMXC__Service_Request__c>> srMap = new Map<Id, set<SVMXC__Service_Request__c>>();
        Map<Id, Set<SVMXC__Service_Order__c>> woMap = new Map<Id, Set<SVMXC__Service_order__c>>();
        Map<Id, Set<SIG_Administrative_Task__c>> atMap = new Map<Id, Set<SIG_Administrative_Task__c>>();
        Map<String, set<SVMXC__Service_Request__c>> userSRMap = new Map< String, set<SVMXC__Service_Request__c>>();
        Map<String, set<SVMXC__Service_Order__c>> userWoMap = new Map< String, set<SVMXC__Service_Order__c>>();
        Map<String, set<SIG_Administrative_Task__c>> userATMap = new Map< String, set<SIG_Administrative_Task__c>>();
       
        For(SVMXC__Service_Request__c srVal:scope){
            If(string.valueOf(srVal.OwnerId).startsWith(userStringVal)){
                if(!userSRMap.containsKey(srVal.Owner.Email)){
                userSRMap.put(srVal.Owner.Email,new set<SVMXC__Service_Request__c>{srVal} );
                }else
                {
                   userSRMap.get(srVal.Owner.Email).add(srVal);
                }
            }
            else{
                if(!srMap.containsKey(srVal.OwnerId)){
                    srMap.put(srVal.OwnerId,new set<SVMXC__Service_Request__c>{srVal} );
                }else
                {
                   srMap.get(srVal.OwnerId).add(srVal);
                }
            }
            
            For(SVMXC__Service_Order__c woVal :srVal.SVMXC__Work_Orders__r){
                If(string.valueOf(srVal.OwnerId).startsWith(userStringVal)){
                if(!userWoMap.containsKey(woVal.Owner.Email)){
                userWoMap.put(woVal.Owner.Email,new set<SVMXC__Service_Order__c>{woVal} );
                }else
                {
                   userWoMap.get(woVal.Owner.Email).add(woVal);
                }
            }
            else{
                if(!woMap.containsKey(woVal.OwnerId)){
                    woMap.put(woVal.OwnerId,new set<SVMXC__Service_Order__c>{woVal} );
                }else
                {
                   woMap.get(woVal.OwnerId).add(woVal);
                }
            }
            }
            
            For(SIG_Administrative_Task__c atVal :srVal.Administrative_Tasks__r){
                If(string.valueOf(atVal.OwnerId).startsWith(userStringVal)){
                if(!userATMap.containsKey(atVal.Owner.Email)){
                userATMap.put(atVal.Owner.Email,new set<SIG_Administrative_Task__c>{atVal} );
                }else
                {
                   userATMap.get(atVal.Owner.Email).add(atVal);
                }
            }
            else{
                if(!atMap.containsKey(atVal.OwnerId)){
                    atMap.put(atVal.OwnerId,new set<SIG_Administrative_Task__c>{atVal} );
                }else
                {
                   atMap.get(atVal.OwnerId).add(atVal);
                }
            }
            }
         }
         /***  Group Member Extracting ***/
         
         Set<Id> groupIds = new Set<Id>();
         groupIds.addAll(srMap.keyset());
         groupIds.addAll(woMap.keyset());
         groupIds.addAll(atMap.keyset());
         Map<Id,Set<user>> GpMap = new Map<Id,Set<User>>();
         
         Map<Id,User> userVal = new Map<Id,User>([SELECT User.Id, User.Email FROM User WHERE Id IN 
                                                (SELECT UserOrGroupId FROM GroupMember WHERE GroupId in : groupIds)]);
         
         
         For(GroupMember gm :[Select groupId, UserOrGroupId From GroupMember where groupId IN : groupIds]){
             if(GpMap.containsKey(gm.groupId)){
                 GpMap.get(gm.groupId).add(userVal.get(gm.UserOrGroupId));
             }else{
                 GpMap.put(gm.groupId,new set<User>{userVal.get(gm.UserOrGroupId)});
             }
         }
         // Extracting group member from Service Request
         
         If(!GpMap.isEmpty() && !srMap.isEmpty()){
         For(Id gVal : GpMap.keyset()){
              For(User usVal : GpMap.get(gVal)){
                if(!userSRMap.containsKey(usVal.Email)){
                userSRMap.put(usVal.Email,new set<SVMXC__Service_Request__c>(srMap.get(gVal)));
                }
                else
                {
                   userSRMap.get(usVal.Email).addAll(srMap.get(gVal));
                }
              }
         }
         }
        
         
          // Extracting group member from Work Order
          
         If(!GpMap.isEmpty() && !woMap.isEmpty()){
         For(Id gVal : GpMap.keyset()){
              For(User usVal : GpMap.get(gVal)){
                 if(!userWoMap.containsKey(usVal.Email)){
                 userWoMap.put(usVal.Email,new set<SVMXC__Service_Order__c>(woMap.get(gVal)));
                }
                else
                {
                   userWoMap.get(usVal.Email).addAll(woMap.get(gVal));
                }
              }
         }
         }
          // Extracting group member from Service Request
          
          If(!GpMap.isEmpty() && !atMap.isEmpty()){
         For(Id gVal : GpMap.keyset()){
              For(User usVal : GpMap.get(gVal)){
                  
                if(!userSRMap.containsKey(usVal.Email)){
                userATMap.put(usVal.Email,new set<SIG_Administrative_Task__c>(atMap.get(gVal)));
                }
                else
                {
                   userATMap.get(usVal.Email).addAll(atMap.get(gVal));
                }
              }
         }
         }
         
         // Sending Email for Service Request
          For(String userval1: userSRMap.keyset()){
           For(SVMXC__Service_Request__c srlistval: userSRMap.get(userval1)){
                Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
                Id templateId =  [select id, name from EmailTemplate where developername = 'SIG_Service_Request_Escalation_Email'].id;
                email.setTargetObjectId(srlistval.ownerId);
                email.setWhatId(srlistval.Id);
                email.setTemplateId(templateId);
                email.setSaveAsActivity(false);
                Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
            }
          }
          
          // Sending Email For Work Order
      
          For(String userval1: userWoMap.keyset()){
    
           For(SVMXC__Service_Order__c woListVal: userWoMap.get(userval1)){
         
                Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
                Id templateId =  [select id, name from EmailTemplate where developername = 'SIG_Work_Order_Escalation_Email'].id;
                email.setTargetObjectId(woListVal.ownerId);
                email.setWhatId(woListVal.Id);
                email.setTemplateId(templateId);
                email.setSaveAsActivity(false);
                Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
            }
          }
          
          // Sending Email For Admin  Task
           For(String userval1: userATMap.keyset()){
           
           For(SIG_Administrative_Task__c adListVal: userATMap.get(userval1)){
                Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
                Id templateId =  [select id, name from EmailTemplate where developername = 'SIG_Service_Request_Escalation_Email'].id;
                email.setTargetObjectId(adListVal.ownerId);
                email.setWhatId(adListVal.Id);
                email.setTemplateId(templateId);
                email.setSaveAsActivity(false);
                Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
            }
          }
          
          
          
    }
    
    global void finish(database.BatchableContext bc) {
        
    }
}

Hi, I want to change my column from 'Name' into 'Queue Name'. Is it possible?

User-added image

my VF code

 

<apex:page controller="Search_For_User">
<apex:form style="width: 500px" >
       <apex:pageBlock tabStyle="Account" >

              <apex:inputText value="{!keyword}"/>
              <apex:commandButton value="Search" action="{!searchUser}"/>

            <Apex:pageblockTable value="{!results}" var="r" style="width: 450px">
                  <apex:column value="{!r.FirstName}" />
                  <apex:column value="{!r.LastName}" />
                  <apex:column value="{!r.ProfileId}"/>
            </Apex:pageblockTable>
              <Apex:pageblockTable value="{!groupMembers}" var="g" style="width: 200px">
                  <apex:column value="{!g.Group.Name}"/>
           </Apex:pageblockTable>
            
       </apex:pageBlock>
</apex:form>
</apex:page>
  • September 05, 2019
  • Like
  • 0
Hi, can someone guide me how can i cover atleast 75 of this class?
 
public class WorkOrderRelatedList{
    
    public SVMXC__Service_Order_Line__c[] WorkDetailList{get;set;}
    String u = UserInfo.getUserId();
    public WorkOrderRelatedList(ApexPages.standardController std){
        WorkDetailList=new SVMXC__Service_Order_Line__c[]{};
         string WorkOrderId=ApexPages.currentPage().getParameters().get('id');
        if(WorkOrderId==NULL){
            system.debug('No Id available');
        }
        else{
            SVMXC__Service_Order__c[] AccWL=new SVMXC__Service_Order__c[]{};
            AccWL=[Select id,  (select ID, Name, lastmodifieddate, SVMXC__Line_Type__c,SVMXC__Product__c, SVMX_PS_Consumed_Qty__c, SIG_SC_Description__c, SVMXC__Group_Member__c, 
                                       SVMX_PS_Customer_Start_Date__c, SVMX_PS_Customer_Start_Time__c, SVMX_PS_Customer_End_Time__c, SVMX_PS_Customer_End_Date__c, SIG_Duration_Hours__c
                                from SVMXC__Service_Order_Line__r where (SVMXC__Line_Type__c = 'Labor' AND  CreatedById =:  u) OR (SVMXC__Line_Type__c = 'Travel' AND  CreatedById =:  u ) OR SVMXC__Line_Type__c = 'Parts' )  
                  from SVMXC__Service_Order__c where id =:WorkOrderId];
            for( SVMXC__Service_Order__c c:AccWL ){
                for(SVMXC__Service_Order_Line__c obj:c.SVMXC__Service_Order_Line__r ){
                    WorkDetailList.add(obj);
                }
            }
        }
    }
}



I only covered 45%...

 

@isTest
class WorkOrderRelatedList_UT{

    @isTest
    static void testtMethod() 
    { 
          String u = UserInfo.getUserId();
          SVMXC__Service_Order__c woTest = new SVMXC__Service_Order__c();
          woTest.SVMXC__Priority__c = 'Normal';
          insert woTest;
          
          SVMXC__Service_Order__c wo = [Select ID from SVMXC__Service_Order__c where Id =: woTest.id];
         
        
         ApexPages.StandardController sc = new ApexPages.StandardController(woTest);
         WorkOrderRelatedList testWo     = new WorkOrderRelatedList(sc);
        
         PageReference pageRef = Page.WorkDetailRelatedList; // Add your VF page Name here
         pageRef.getParameters().put('id', String.valueOf(wo.Id));
         Test.setCurrentPage(pageRef);
         
         SVMXC__Service_Order_Line__c workDetail = new SVMXC__Service_Order_Line__c();
         workDetail.SVMXC__Service_Order__c = wo.Id;
         workDetail.RecordTypeId = '0121i000000Gs2VAAS';
         workDetail.SVMXC__Line_Type__c = 'Labor';
         
         insert workDetail;
        
        
    }
}


My visualforce page:

 

<apex:page standardController="SVMXC__Service_Order__c" extensions="WorkOrderRelatedList" tabStyle="SVMXC__Service_Order_Line__c" lightningStylesheets="true">
<style>
body .bPageBlock .pbBody .labelCol{
     float:left;
}
</style>
    
    <apex:pageBlock Title="My Work Details">
        
            <apex:pageBlockTable style="width:100%" value="{!WorkDetailList}" var="n" >
                <apex:column style="width:50px" headerValue="Line Number" value="{!n.Name}"/>
                <apex:column style="width:50px" headerValue="Line Type" value="{!n.SVMXC__Line_Type__c}" />
                <apex:column style="width:10px" headerValue="Part" value="{!n.SVMXC__Product__c}" />
                <apex:column style="width:1px" headerValue="Consumed Qty" value="{!n.SVMX_PS_Consumed_Qty__c}" />
                <apex:column style="width:10px" headerValue="SC Description" value="{!n.SIG_SC_Description__c}" />
                <apex:column style="width:10px" headerValue="Technician" value="{!n.SVMXC__Group_Member__c}" />
                <apex:column style="width:10px" headerValue="Reported Start Date" value="{!n.SVMX_PS_Customer_Start_Date__c}" />
                <apex:column style="width:10px" headerValue="Reported Start Time" value="{!n.SVMX_PS_Customer_Start_Time__c}" />
                <apex:column style="width:10px" headerValue="Reported End Date" value="{!n.SVMX_PS_Customer_End_Date__c}" />
                <apex:column style="width:10px" headerValue="Reported End Time" value="{!n.SVMX_PS_Customer_End_Time__c}" />
                <apex:column style="width:10px" headerValue="Duration(hours)" value="{!n.SIG_Duration_Hours__c}" />


           
   </apex:pageBlockTable>
        
        
    </apex:pageBlock>    
    
</apex:page>

​​​​​​​
  • September 22, 2020
  • Like
  • 0
Hi, I have this trigger which checks if I have a duplication(Dispatcher) in each Service Team.
trigger AvoidduplicateDispatcher on SVMXC__Dispatcher_Access__c (before insert) {

// for every new dispatcher created fetches the id of the service team selected in serviceTeamMap
    map<Id, Set<String>> serviceTeamMap = new map<Id, Set<string>>();
    for(SVMXC__Dispatcher_Access__c disp: trigger.new){
        if(disp.SVMXC__Service_Team__c!= null){
            serviceTeamMap.put(disp.SVMXC__Service_Team__c, new set<String>());
            system.debug('************'+serviceTeamMap);
        }
     }
     

    if(!serviceTeamMap.isEmpty()){
        for(SVMXC__Dispatcher_Access__c disp1: [Select Id, SVMXC__Dispatcher__c, SVMXC__Service_Team__c from SVMXC__Dispatcher_Access__c where SVMXC__Service_Team__c =: serviceTeamMap.keySet()]){
            serviceTeamMap.get(disp1.SVMXC__Service_Team__c).add(disp1.SVMXC__Dispatcher__c);
        }
        system.debug('******serviceTeamMap*****'+serviceTeamMap);
    }
    
    if(!serviceTeamMap.isEmpty()){
        for(SVMXC__Dispatcher_Access__c dispRec: trigger.new){
            system.debug('************'+dispRec.SVMXC__Dispatcher__c);
             Set<String> dispSet = serviceTeamMap.get(dispRec.SVMXC__Service_Team__c);
             system.debug('************dispSet '+dispSet);
             if(dispSet.contains(dispRec.SVMXC__Dispatcher__c)){
                 system.debug('************'+dispRec.SVMXC__Dispatcher__c);
                     dispRec.addError('You are already a dispatcher in this Service Team!');
             }  
             
        }
    }

}


This is my Test Class.

@isTest
public class AvoidduplicateDispatcher_UT {
    @isTest static void AvoiDuplicateDispatcher_TestMethod(){
        SVMXC__Dispatcher_Access__c dp = new SVMXC__Dispatcher_Access__c();
        dp.SVMXC__Dispatcher__c = '0051i0000012ogr';
        dp.SVMXC__Service_Team__c = 'a341i000000PBPY';
        insert dp;
        
        SVMXC__Dispatcher_Access__c dp1 = new SVMXC__Dispatcher_Access__c();
        dp1.SVMXC__Dispatcher__c = '0051i0000012ogr';
        dp1.SVMXC__Service_Team__c = 'a341i000000PBPY';
        Database.SaveResult sresult = Database.insert(dp1, false); 
    }
}


I have 100% coverage.

 

However in PROD when i want to migrate I have this error:

 

System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, You are already a dispatcher in this Service Team!: []
Stack Trace: Class.AvoidduplicateDispatcher_UT.AvoiDuplicateDispatcher_TestMethod: line 12, column 1

How can i fix this guys?​​​​​​​

Hi, I have two objects.

Dispatcher(SVMXC__Dispatcher_Access__c) and Service Team(SVMXC__Service_Group__c).

The relationship between Dispatcher and the Service Team is many to one, in other words there can be multiple dispatchers associated to one Service Team. 

Here is a picture to make you understand:For example, we have this team AP-S-Indonesia FSE and we have 6 dispatchers related to this Service Team.
User-added image

I want to create a trigger to fetch all the Dispatchers related to this Service Team. Any suggestions?

Hi! I have created a trigger:

trigger SIG_permissionToEditAdminTasks on SIG_Administrative_Task__c (before update) {
       

         SVMXC__Service_Order__c queueOwner = new SVMXC__Service_Order__c();
        ApexPages.StandardController sc = new ApexPages.StandardController(queueOwner);
       SIG_QueueOwnerUpdate classQueue = new SIG_QueueOwnerUpdate(sc);
         
         
         
          public Set<String> memberIds = new Set<String>();
          String currentUserID = UserInfo.getUserId();
          SIG_Administrative_Task__c admTask = new SIG_Administrative_Task__c();
          
          
     
      //fetch the id of the creator of the record <start>
           Set<String> ownerIds = new Set<String>();
        for (SIG_Administrative_Task__c record : Trigger.New) {
            ownerIds.add(record.OwnerId);
             
        }
        
      // <end>
        
        List<Group> groups = [SELECT Id, (SELECT Id, UserOrGroupId FROM GroupMembers) FROM Group WHERE Id =: ownerIds];
        System.debug('####groups' + groups);    
        
          
         Set<String> memberIdsByGroupId = new Set <String>();
   
        //fetch the id's of the users from the the current owner queue  <start>
        for (Group groupRec : groups) {
         
            for (GroupMember member : groupRec.GroupMembers) {
                memberIds.add(member.UserOrGroupId);
            }
              
        }
        // <end>
       system.debug('memberIds123'+memberIds);

         for (SIG_Administrative_Task__c record : Trigger.New) {
            if((memberIds.contains(currentUserID) || record.createdById == UserInfo.getUserId() || record.OwnerID == UserInfo.getUserId() ))
            {
           
            }
            else
            {
               record.addError('You need to be the owner or to be inside of a queue to edit an Admin Task');
            }
        }
    

}

On this line I am trying to call a class in my trigger:

ApexPages.StandardController sc = new ApexPages.StandardController(queueOwner);
 SIG_QueueOwnerUpdate classQueue = new SIG_QueueOwnerUpdate(sc);


Everything looks fine.. but when I try to activate my trigger and do an update on a record i have this error:

User-added imageWhen i took a look in my class, line 73 this is what I see:

User-added imageHow can I call my class without getting this error?

Hello, I want to update my attachments name after they are created. This works but the name of the Work Order(custom object) is not automatically. User-added imageThis is my attachments and you can see Related to : WO-0003061.

my trigger, it works if i hard code the name:

 

trigger SetTitleToAttachment on Attachment (before insert) { 


        for(Attachment a: Trigger.new){
          
            if(a.Name.startsWith('SIG_PM_Work_Order_Service_Report')){
                a.Name = 'Work Order name dynamically ';
            } else if (a.Name.startsWith('SIG_HandoverCheckList_Customer_To_SIG_Report')){
                a.Name = 'ServiceReport.pdf';
            }
            
        }


}


I want to on the line  a.Name = 'Work Order name dynamically '; to be instead of this string to be the name WO-0003061. How can i do this?

Please help. I would appreciate a lot :)

Hello,

I have a small trigger:
 

trigger SetTitleToAttachment on Attachment (after insert) { 

    
    //store the ID of the new attachment
    ID attachment;
    ID workOrder;

    
    
    for (Attachment att : Trigger.new) {
        attachment = att.ID;
        workOrder = att.ParentId;
       
        
    }
   Map<ID, SVMXC__Service_Order__c> wo =new Map<ID, SVMXC__Service_Order__c>( [SELECT ID, NAME, SVMX_PS_Ship_To_Name__c from SVMXC__Service_Order__c WHERE ID =: workOrder ]);


}


My question is: how can I access the fieds: Name and SVMX_PS_Ship_To_Name__c from this map?

I'm confused. 

Hello, I have a requirement to create a trigger to not allow users to edit records if they are not the creator OR if they are not the owner. Owner can be a simple user or a QUEUE.
 

This is what I wrote until now... my code is not working.

 

trigger permissionToEditAdminTasks on SIG_Administrative_Task__c (after update) {
  
      //fetch the id of the creator of the record <start>
           Set<String> ownerIds = new Set<String>();
        for (SIG_Administrative_Task__c record : Trigger.New) {
            ownerIds.add(record.OwnerId);
             
        }
        
       
        
      // <end>
        
        List<Group> groups = [SELECT Id, (SELECT Id, UserOrGroupId FROM GroupMembers) FROM Group WHERE Id =: ownerIds];
        System.debug('####groups' + groups);    
        
          
        Map<String, Set<String>> memberIdsByGroupId = new Map<String, Set<String>>();
        
        //fetch the id's of the users from the the current owner queue  <start>
        for (Group groupRec : groups) {
            Set<String> memberIds = new Set<String>();
            for (GroupMember member : groupRec.GroupMembers) {
                memberIds.add(member.UserOrGroupId);
            }
               System.debug('####memberIds  ' + memberIds );   
        }
        // <end>
       

        for (SIG_Administrative_Task__c record : Trigger.New) {
            if (memberIdsByGroupId.get(record.OwnerId) != null && memberIdsByGroupId.get(record.OwnerId).contains(UserInfo.getUserId()))
            {
             
            }else{
                 record.addError('You have not permission for editing this record');
                  System.debug('record.OwnerId' + record.OwnerId);
            }
        }
    

}
I cannot edit the record no matter what, I don't know what is wrong in my code.. please help.
Hi! I want to create a class that will fetch the ID of an Account dynamic when I create a new record. We have a custom object named Account Change request. This object can be found in the related lists from Account. When user press to create a new Account Change Request I want to override it with my visualforce page, thus I would need to display the informations on my VF page from that Account. I tried to create by myself but it's not working..
 
public class MasterDataChange{


 public Account parentAccount{get; set;}
 public Account_Change_Request__c accChangeRequest;


 public MasterDataChange(ApexPages.StandardController controller){
    
  String parentAccId = ApexPages.currentPage().getParameters().get('id');
     if(parentAccId != null){
            parentAccount= [SELECT Id, Name FROM Account WHERE Id = :parentAccId limit 1];
                accChangeRequest.Account__c = parentAccount.Id;
            }
         
        } 

  
 public PageReference save(){
   insert accountChangeRequest;
   
    PageReference pg = new PageReference('/'+parentAccount.Id);
          pg.setRedirect(true);
         return pg;
 }
}

Account__c is my master-detail with the Account object.. please help.