• Sarah Paulson
  • NEWBIE
  • 54 Points
  • Member since 2019
  • Admin

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 14
    Questions
  • 29
    Replies

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>


Hi, I have this error on my code:

 

public class Search_For_User
{
    String keyword;

    List<user>results = new List<user>();
    
    public String getkeyword(){
    return keyword;
    }
   
    public List<user> getresults(){
    return results;
    }
    
    public void setkeyword(String input){
    keyword = input;
    }
    
    public PageReference searchUser(){
    results = (List<User>)[FIND :keyword IN NAME FIELDS RETURNING USER(FirstName, LastName, ProfileId)][0];
    return null;
 
    }

     System.debug(results);
 
    
}
Can someone help me please...
I created a multiselect picklist in jQuery and it looks like this:User-added imagenow the code for this is: 
<!DOCTYPE html>
<html lang="en-us">
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
</head>

<body>
<table>
<tr>
<td><select id="picklist1" multiple></select></td><td></td>
<td><select id="picklist2" multiple></select></td><td></td>
<td><select id="picklist3" multiple></select></td><td></td>
</tr>
</table>

<script>
(function($) {
	$.fn.multipicklist = function( options ) {
		var source = $(this[0]);
		var target = $(this[1]);
		if (options && options.length > 0) {
			$.each(options, function (i, item) {
				source.append($('<option>', {
    					value: i,
    					text: item
				}));
			});
		}

		var td = source.parent().next();
		td.append($('<p><a id="addTo' + target.attr('id') + '" href="#">&gt;</a></p>'));
		td.append($('<p><a id="subtractFrom' + target.attr('id') + '" href="#">&lt;</a></p>'));

		 $("#addTo" + target.attr('id')).click(function (e) { 
			target.append(source.find(":selected"));
			source.find(":selected").remove();
		});
		$("#subtractFrom" + target.attr('id')).click(function (e) { 
			source.append(target.find(":selected"));
			target.find(":selected").remove();
		});
	};

}(jQuery));

$("#picklist1, #picklist2").multipicklist(["option1","option2","option3","option4"]);
$("#picklist2, #picklist3").multipicklist();
</script>
</body>
</html>

And for this requirement I need the values from my picklist field instead of "option1","option2","option3","option4". Question is: How can get the values from my picklist field? I created a variable like this:

public Visit_Report__c record {get; set;}


then somewhere in my code, in my VF page i need to add this, I think:​​​​​​​

!record.Innovation_presented_to_customer__c
Any ideas how to implement this?
hi, i'm a newbie in development and i have this task to add one more box in the VF page. Now, we have only 2 boxes one is Available and the other one is Chosen.. but now the client wants one more box and it has to be like this: First box - Available, Second box - Presented, third box - Interested... and I don't know how to add the third box. I tried to look up in the code and I found the code which make this boxes...User-added imageUser-added imageI'm not sure how to add the third box in here... some suggestions, please?

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, 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...

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?