• Brian Romanowski
  • NEWBIE
  • 10 Points
  • Member since 2014
  • Software Developer
  • Merchants Fleet Management

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 11
    Replies
Hi everyone,
I work as a Salesforce Developer here at Merchants Fleet in NH. We are looking to expand our team and was wondering if anyone in the group might be interested. We are in need or a Salesforce Developer(HERE) and a Salesforce QA Engineer(HERE).
Thanks!
Brian
Pretty straight forward. We have all our profile pictures in Active Directory and want to get them into Salesforce. Is there a way to sync them?
We have a use case where the creator of the idea may need to be anonymous. We are using ideas internally and there can be cost saving ideas that may result in positions being eliminated so we would like the submitters to be able to be anonymous from other users. I have 2 custom fields, a check box for anonymous, and then a calculated field that displays the user if not anonymous or links to a dummy user if it is anonymous. We need to hide the creator field now but I haven't been able to access it through the profiles in the metadata api or change the page layout to not include it. Anyone have any ideas?
I'm trying to create a list of related ID's to a custom object, Base Elements. I check if the value is null in the SOQL and put in a conditioonal statement checking it again but when I go to add it to the list I get the System.NullPointerException: Attempt to de-reference a null object. I underlined the add statement that is causing the error. Any idea what is going on?

FOR (BMCServiceDesk__BMC_BaseElement__c b : [SELECT BMCServiceDesk__PrimaryClient__c FROM BMCServiceDesk__BMC_BaseElement__c WHERE BMCServiceDesk__PrimaryClient__c!=null ]) {
        system.debug('pc: '+b.BMCServiceDesk__PrimaryClient__c);
        if(b.BMCServiceDesk__PrimaryClient__c!=null){
            system.debug('this is not null!!');
            bepc.add(b.BMCServiceDesk__PrimaryClient__c);
        }
	}


I have part of a trigger setting the owner of a record when they edit it. I've tested it manually and it's working but my assertion in my test is failing and I can't figure out why. What am I missing??

Trigger:
if (Trigger.isBefore){           
		if (Trigger.isInsert){     
                        // LOGIC TO BE EXECUTED FOR BEFORE INSERT
		}
        //END BEFORE INSERT
		if (Trigger.isupdate){   
                        // LOGIC TO BE EXECUTED FOR BEFORE UPDATE
			//*******************************************************************
            //***********INCIDENT OWNER SET TO STAFF MEMBER WHEN THEY EDIT**************
            //*******************************************************************
            // Create a set of staff ID's
			Set<ID> staffID = new Set<ID>();
			FOR (User s : [select Id from User WHERE BMCServiceDesk__IsStaffUser__c = true AND isactive = True ]) {
    			staffID.add(s.ID);
   			}
	
    		//check if user editing incident is staff
			if(staffID.contains(Userinfo.getUserId())){
			//iterate through the qualifying incidents and set the owner to the staff member editing it   
				FOR (BMCServiceDesk__Incident__c i : Trigger.new){       
					//If they are not changing the owner to someone else set the owner to the current staff user
                    if(Trigger.oldMap.get(i.Id).OwnerID == i.OwnerId){        
						i.OwnerId=Userinfo.getUserID();
        			} 
        		}
    		} 
		}
        //END BEFORE UPDATE
	}
My Test:
@IsTest
public class testmethodtests {
public static testMethod void UpdatedByStaffAssignment() { 
   
    	BMCServiceDesk__Category__c cat = new BMCServiceDesk__Category__c ( Name = 'TestCat',BMCServiceDesk__AvailableForIncidents__c=TRUE);
    		insert cat;
		
        BMCServiceDesk__Status__c teststat = new BMCServiceDesk__Status__c ( Name = 'Teststat');
			insert teststat;    
        
    	User usr = [select Id from User where BMCServiceDesk__IsStaffUser__c = FALSE AND isactive = True LIMIT 1];
        
		User staff = [select Id from User where BMCServiceDesk__IsStaffUser__c = TRUE AND isactive = True  LIMIT 1];

    	User thisUser = [ select Id from User where Id = :UserInfo.getUserId() ];
        
  		BMCServiceDesk__Incident__c inc = new BMCServiceDesk__Incident__c(Ownerid = usr.id,Subject__c='Testy', BMCServiceDesk__FKCategory__c = cat.Id,Status_Map__c='Opened');
			insert inc;	
    	
					
    	test.startTest(); 
            System.runAs(staff) {
    		inc.Status_Map__c = 'Teststat';
    		update inc;
            }
    	test.stopTest();
        
    	BMCServiceDesk__Incident__c updatedInc = [SELECT Id , ownerid FROM BMCServiceDesk__Incident__c WHERE Id = :inc.id];
    	system.debug('usr id'+usr.id);
        system.debug('stf id'+staff.id);
        system.debug('ownr id'+updatedInc.ownerid);
        system.assertEquals(staff.id, updatedInc.ownerid);  
	}


Is there a way to link directly into a detail record in the Salesforce1 mobile browser app? I've seen the links for going directly into the Salesforce1 App but I'm looking for it to open in the browser(Safari for iOS). Just sending the regular link does not redirect to the mobile version of the detail record. I do have Enable the Salesforce1 mobile browser app set to true but that appears to only work when you are logging in, not when you are going to a specific record.
Thanks,
Brian
I've been searching and unable to find anything. Has anyone dealt with a requirement to assign an object owner based on a calendar schedule? Our requirement is for our service desk. We have after hours support but it is based on a schedule so our custom incident object needs to be assigned based on that schedule. Any help or ideas is much appreciated.
I'm trying to utilize some code from the apex guide to share records. I'm getting the too many DML statements error when I run my bulk tests. The bulk test is just inserting a list of 200 objects. The code I modified is here:http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_bulk_sharing_creating_with_apex.htm

Error: System.LimitException: Too many DML statements: 151
Stack Trace: Class.IncidentSharing.manualShareRead: line 25, column 1
Trigger.IncidentTrigger: line 39, column 1

Line 25 column 1 is Database.SaveResult sr = Database.insert(incShr,false);

I realize the insert is running on every call but I don't know how to fix it. Should I pass a map to the class? Can I build a list inside the class and then insert it? I tried building a list and then inserting it but then how do I process the return? Thanks

Trigger Code 
FOR( BMCServiceDesk__Incident__c i : [SELECT id, BMCServiceDesk__Client_Manager__c FROM BMCServiceDesk__Incident__c WHERE (Equipment_Request__c= true OR Manager_Approval__c = true) AND Id IN: trigger.new ]) {
                IncidentSharing.manualShareRead(i.id,i.BMCServiceDesk__Client_Manager__c);
            }
Apes sharing class 
public class IncidentSharing {
   
   public static boolean manualShareRead(Id recordId, Id userOrGroupId){
   //public static boolean manualShareRead(map<Id,Id>){
      // Create new sharing object for the custom object Incident.
      BMCServiceDesk__incident__Share incShr  = new BMCServiceDesk__incident__Share();
       
      // Set the ID of record being shared.
      incShr.ParentId = recordId;
        
      // Set the ID of user or group being granted access.
      incShr.UserOrGroupId = userOrGroupId;
        
      // Set the access level.
      incShr.AccessLevel = 'Read';
        
      // Set rowCause to 'manual' for manual sharing.
      // This line can be omitted as 'manual' is the default value for sharing objects.
      incShr.RowCause = Schema.BMCServiceDesk__incident__Share.RowCause.Manual;
        
 
      // Insert the sharing record and capture the save result. 
      // The false parameter allows for partial processing if multiple records passed 
      // into the operation.
      Database.SaveResult sr = Database.insert(incShr,false);
      
 
      // Process the save results.
      if(sr.isSuccess()){
         //Indicates success
         return true;
      }
      else {
         // Get first save result error.
         Database.Error err = sr.getErrors()[0];
         
         // Check if the error is related to trival access level.
         // Access levels equal or more permissive than the object's default access level are not allowed. 
         // These sharing records are not required and thus an insert exception is acceptable. 
         if(err.getStatusCode() == StatusCode.FIELD_FILTER_VALIDATION_EXCEPTION  &&  
                  err.getMessage().contains('AccessLevel')){
            // Indicates success.
            return true;
         }
         else{
            //Indicates failure.
            return false;
         }
         
		}
   }	
}


I am an admin attempting to modify a prior LREngine class in our Salesforce to rollup activity records onto Leads. I want to only rollup activities that meet certain criteria and am able to do so fine with one criteria but when I add 2 criteria I get a 'Constructor not defined' error so it seems the code doesn't allow more than one field result entry. Does anyone know a way around that so I can add multiple criteria?

Code is below. I'm getting an error on the second critiera where 'RecordType = \'Demo\''
public class ActivityRollups {



    public static void doRollups(Task[] objects) {


        LREngine.Context ctx = new LREngine.Context(Lead.SobjectType, // parent object
                                               Task.SobjectType, // child object
                                               Schema.SObjectType.Task.fields.WhoID // relationship field name
                                               );     

        ctx.add(
               new LREngine.RollupSummaryField(
                                               Schema.SObjectType.Lead.fields.Demos_Attended__c,
                                               Schema.SObjectType.Task.fields.id,
                                               LREngine.RollupOperation.Count 
                                            ));


    
        LREngine.Context ctxDemoAttended = new LREngine.Context(Lead.SobjectType, // parent object
                                               Task.SobjectType, // child object
                                                Schema.SObjectType.Task.fields.WhoID, // relationship field name
                                                'Call_Status__c = \'Attended\'', // filter / field result
                                                'RecordType = \'Demo\'' // filter / field result
                                                );


         Sobject[] masters = LREngine.rollUp(ctx, objects);
         Sobject[] mastersDemoAttended = LREngine.rollUp(ctxDemoAttended, objects);


        updateRecords(masters);
        masters = null;


        updateRecords(mastersDemoAttended);
        mastersDemoAttended = null;

    }


    private static void updateRecords(Sobject[] pMasters) {
        try {
            update pMasters;
        }
        catch (System.DMLException ex) {
            String s = ex.getMessage();
            if (s.containsIgnoreCase('FIELD_CUSTOM_VALIDATION_EXCEPTION') && !Trigger.IsDelete) {
                Trigger.New[0].addError( s.substring( s.indexof('FIELD_CUSTOM_VALIDATION_EXCEPTION')+35,  s.indexof(': [') ) );
                return;
            } else {
                throw ex;
            }
        }
    }


}

 
Hi everyone,
I work as a Salesforce Developer here at Merchants Fleet in NH. We are looking to expand our team and was wondering if anyone in the group might be interested. We are in need or a Salesforce Developer(HERE) and a Salesforce QA Engineer(HERE).
Thanks!
Brian
Pretty straight forward. We have all our profile pictures in Active Directory and want to get them into Salesforce. Is there a way to sync them?
I'm trying to create a list of related ID's to a custom object, Base Elements. I check if the value is null in the SOQL and put in a conditioonal statement checking it again but when I go to add it to the list I get the System.NullPointerException: Attempt to de-reference a null object. I underlined the add statement that is causing the error. Any idea what is going on?

FOR (BMCServiceDesk__BMC_BaseElement__c b : [SELECT BMCServiceDesk__PrimaryClient__c FROM BMCServiceDesk__BMC_BaseElement__c WHERE BMCServiceDesk__PrimaryClient__c!=null ]) {
        system.debug('pc: '+b.BMCServiceDesk__PrimaryClient__c);
        if(b.BMCServiceDesk__PrimaryClient__c!=null){
            system.debug('this is not null!!');
            bepc.add(b.BMCServiceDesk__PrimaryClient__c);
        }
	}


I have part of a trigger setting the owner of a record when they edit it. I've tested it manually and it's working but my assertion in my test is failing and I can't figure out why. What am I missing??

Trigger:
if (Trigger.isBefore){           
		if (Trigger.isInsert){     
                        // LOGIC TO BE EXECUTED FOR BEFORE INSERT
		}
        //END BEFORE INSERT
		if (Trigger.isupdate){   
                        // LOGIC TO BE EXECUTED FOR BEFORE UPDATE
			//*******************************************************************
            //***********INCIDENT OWNER SET TO STAFF MEMBER WHEN THEY EDIT**************
            //*******************************************************************
            // Create a set of staff ID's
			Set<ID> staffID = new Set<ID>();
			FOR (User s : [select Id from User WHERE BMCServiceDesk__IsStaffUser__c = true AND isactive = True ]) {
    			staffID.add(s.ID);
   			}
	
    		//check if user editing incident is staff
			if(staffID.contains(Userinfo.getUserId())){
			//iterate through the qualifying incidents and set the owner to the staff member editing it   
				FOR (BMCServiceDesk__Incident__c i : Trigger.new){       
					//If they are not changing the owner to someone else set the owner to the current staff user
                    if(Trigger.oldMap.get(i.Id).OwnerID == i.OwnerId){        
						i.OwnerId=Userinfo.getUserID();
        			} 
        		}
    		} 
		}
        //END BEFORE UPDATE
	}
My Test:
@IsTest
public class testmethodtests {
public static testMethod void UpdatedByStaffAssignment() { 
   
    	BMCServiceDesk__Category__c cat = new BMCServiceDesk__Category__c ( Name = 'TestCat',BMCServiceDesk__AvailableForIncidents__c=TRUE);
    		insert cat;
		
        BMCServiceDesk__Status__c teststat = new BMCServiceDesk__Status__c ( Name = 'Teststat');
			insert teststat;    
        
    	User usr = [select Id from User where BMCServiceDesk__IsStaffUser__c = FALSE AND isactive = True LIMIT 1];
        
		User staff = [select Id from User where BMCServiceDesk__IsStaffUser__c = TRUE AND isactive = True  LIMIT 1];

    	User thisUser = [ select Id from User where Id = :UserInfo.getUserId() ];
        
  		BMCServiceDesk__Incident__c inc = new BMCServiceDesk__Incident__c(Ownerid = usr.id,Subject__c='Testy', BMCServiceDesk__FKCategory__c = cat.Id,Status_Map__c='Opened');
			insert inc;	
    	
					
    	test.startTest(); 
            System.runAs(staff) {
    		inc.Status_Map__c = 'Teststat';
    		update inc;
            }
    	test.stopTest();
        
    	BMCServiceDesk__Incident__c updatedInc = [SELECT Id , ownerid FROM BMCServiceDesk__Incident__c WHERE Id = :inc.id];
    	system.debug('usr id'+usr.id);
        system.debug('stf id'+staff.id);
        system.debug('ownr id'+updatedInc.ownerid);
        system.assertEquals(staff.id, updatedInc.ownerid);  
	}


I've been searching and unable to find anything. Has anyone dealt with a requirement to assign an object owner based on a calendar schedule? Our requirement is for our service desk. We have after hours support but it is based on a schedule so our custom incident object needs to be assigned based on that schedule. Any help or ideas is much appreciated.
I'm trying to utilize some code from the apex guide to share records. I'm getting the too many DML statements error when I run my bulk tests. The bulk test is just inserting a list of 200 objects. The code I modified is here:http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_bulk_sharing_creating_with_apex.htm

Error: System.LimitException: Too many DML statements: 151
Stack Trace: Class.IncidentSharing.manualShareRead: line 25, column 1
Trigger.IncidentTrigger: line 39, column 1

Line 25 column 1 is Database.SaveResult sr = Database.insert(incShr,false);

I realize the insert is running on every call but I don't know how to fix it. Should I pass a map to the class? Can I build a list inside the class and then insert it? I tried building a list and then inserting it but then how do I process the return? Thanks

Trigger Code 
FOR( BMCServiceDesk__Incident__c i : [SELECT id, BMCServiceDesk__Client_Manager__c FROM BMCServiceDesk__Incident__c WHERE (Equipment_Request__c= true OR Manager_Approval__c = true) AND Id IN: trigger.new ]) {
                IncidentSharing.manualShareRead(i.id,i.BMCServiceDesk__Client_Manager__c);
            }
Apes sharing class 
public class IncidentSharing {
   
   public static boolean manualShareRead(Id recordId, Id userOrGroupId){
   //public static boolean manualShareRead(map<Id,Id>){
      // Create new sharing object for the custom object Incident.
      BMCServiceDesk__incident__Share incShr  = new BMCServiceDesk__incident__Share();
       
      // Set the ID of record being shared.
      incShr.ParentId = recordId;
        
      // Set the ID of user or group being granted access.
      incShr.UserOrGroupId = userOrGroupId;
        
      // Set the access level.
      incShr.AccessLevel = 'Read';
        
      // Set rowCause to 'manual' for manual sharing.
      // This line can be omitted as 'manual' is the default value for sharing objects.
      incShr.RowCause = Schema.BMCServiceDesk__incident__Share.RowCause.Manual;
        
 
      // Insert the sharing record and capture the save result. 
      // The false parameter allows for partial processing if multiple records passed 
      // into the operation.
      Database.SaveResult sr = Database.insert(incShr,false);
      
 
      // Process the save results.
      if(sr.isSuccess()){
         //Indicates success
         return true;
      }
      else {
         // Get first save result error.
         Database.Error err = sr.getErrors()[0];
         
         // Check if the error is related to trival access level.
         // Access levels equal or more permissive than the object's default access level are not allowed. 
         // These sharing records are not required and thus an insert exception is acceptable. 
         if(err.getStatusCode() == StatusCode.FIELD_FILTER_VALIDATION_EXCEPTION  &&  
                  err.getMessage().contains('AccessLevel')){
            // Indicates success.
            return true;
         }
         else{
            //Indicates failure.
            return false;
         }
         
		}
   }	
}


I have some logic that determines if a approval process needs to be kicked off for an Opportunity that I build into Apex code.  I don't see how I can send the approval process to certain people(may be more than one) and then kick off another one based on certain criteria.  I have code that kicks off an approval process but not one that I choose by name, meaning if I create "First Approval Process" how do I kick off that one without having to create criteria under "Approval Process" section for the "First Approval Process"?  Do I even need to create a Approval Process in order to initiate approval process or can I do all of it through Apex code.

 

Here is what I have that kicks off an Approval Process that I have created with criteria but I find in cumbersome that I can't choose which approval process to kick off.

              //create the new approval request to submit    
            Approval.ProcessSubmitRequest req = new Approval.ProcessSubmitRequest();
            //set the approvers, can only be one :(
            req.setNextApproverIds(approversId);
            req.setComments('Submitted for approval. Please approve.');
              req.setObjectId(EachFlowOpportunity[i].Id);
              // submit the approval request for processing.  How do I choose to kick off "First Approval Process"
              Approval.ProcessResult result = Approval.process(req);

  • October 31, 2012
  • Like
  • 0