• Semira@gmail.com
  • NEWBIE
  • 215 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 2
    Likes Received
  • 2
    Likes Given
  • 59
    Questions
  • 58
    Replies
Hi, 

I'm sort of at a roadblock. Javascript is not my forte and this is first time attempting this. I'm trying to search online to come up with a solution. Any guidance will be helpful. 

What I'm trying to do is create a drop down sort field on Visualforce page. In my controller, I have to query and search for multiple objects with a 'keyword'. When the search results displays, User should be able to sort it by Last modified By. However, since I have different List for each individual object query, how do I create the sort. 

List<connectors__c>
List<article>
List<communityAnswer>

I'm trying to load the data into Javascript array and then sort the array by last modified by. Then display the results. 

Any small code example would be much appreciated or any other online resources. Thank you.
User-added image
Hi, 
Is there a way I can easily find a specific picklist value used in number of classes or workflow, or anywhere in the matadata? 

For example: case status -  Pending ==> I want to deactivte this value or alter the label to say Pending Input. 

How do I find out where is this value is used or listed without having to go through workflow and apex code one at a time? 

Is this possible with Eclipse? If so, can you provide the steps please? If not, is there a free tool I can use? I would truely appreciate any help. 
Hi, 

This might be one of the recurrance questions but I cannot seem to find the answer. I have been trying to resolve this for quiet a few months now. So here is my scenario. 

I have overwritten the New button with a visualforce page of a related list object(invoice__c) from Opportunity. However, this does not work with Console so I tried to write a simple Component re-directing user to the Visualforce page to create a new invoice. When using the lightning component, the ParentID (opportunity ID) is not passed to the new Invoice page. Opportunity has a lookup relationship to invoice. 

How do I pass the opportunity Id through lightning component? 
<aura:component implements="force:appHostable,lightning:actionOverride,flexipage:availableForAllPageTypes,force:hasRecordId" access="global">
  
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    
</aura:component>
Note below: I tried to apply the same method as URL hacking. Obviously it's a fail. I'm not too familiar with URL parameter setting. So, I tried this method to see if it would work. 
({
	doInit : function(component, event, helper) {
		var ID = $A.get("v.recordId");
        var urlEvent = $A.get("e.force:navigateToURL");
    urlEvent.setParams({
        "url":"/apex/ATIInvoicePage?Opportunity__c="+ID
        
    });
    urlEvent.fire();
	}
})

 
Hi, 

I have a String variable in my controller call ChildQuery. I want to pass a value to the string variable from Visualforce page without any javascript or button. How can that be possible? This value needs to be hidden and auto assign as soon as the visualforce page is opened.  

//set the value of Childquery to "write some string value here like ABCD"  without calling <script></script>
// maybe using these tags below? 

<!-- apex:inputHidden  / -->
<!-- apex:param  / -->
<!-- apex:variable / -->

This is what my class would look like. I'm writing a generic class which would be used by many many different visualforce page. So cannot set the value of the variavle in the controller. It has to pass through the visualforce page so I can throw any page and just call this controller class. 
Class sObject {

public string ChildQuery {get; set;}

    public sObjectController(ApexPages.StandardController controller){
      
        system.debug('THIS IS THE VALUE I'M GETTING:' + ChildQuery);

    }

}



 
Hi, 

I'm running into intermittent issue which I cannot seem to catch on debug log. Maybe I don't have right log setup but how do I find out which code (whether it is apex batch or trigger) is causing all our users to get record lock issue when trying to save their changes. 

This happened when I did a mass update to change a value of a picklist. For that I had to turn off a trigger and then turn back on. I made sure all the code in our org are referring to the new value. It started happening when I turned off the trigger which is strange. 

Please if anyone has any suggestion, I'm all open ears. I have case open with support but they aren't able to say much either. 
Hi, 

I am ripping my hair off trying to figure this one out. I'm relatively new at Lightning so not sure if I'm doing this correctly. So I have a button when clicked will call an apex class but the issue is, it needs to first verify the Opportunity Stage being Complete or Won before calling the Apex class. It should also pop up a message informing users that Operation was not successful because the Stage was not Compelete or Won. 

The apex class returns a Status which is success. If so, it should also popup message saying the operations is success. 

Here is my Javascrip I'm trying to convert to Lightning: 
//alert('{!Opportunity.StageName}');
if("{!Opportunity.StageName}" != "Won" && "{!Opportunity.StageName}" != "Complete"){ 
alert("Only Jobs Won or Complete are Synced with EConz."); 
} 
else{ 
var result = sforce.apex.execute("Econz_Controller","invokeIntegration", {OppId:"{!Opportunity.Id}"}); 
if(result == "Success") 
alert("The Job has been synced with EConz."); 
else 
alert("There was an error while syncing. Pls retry again or contact your Administrator"); 
}

Now, here is my Lightning Component:
<aura:component controller="SyncEconzLT" implements="force:lightningQuickActionWithoutHeader,force:hasRecordId" >
    <aura:attribute name="returnMsg" type="String" />
    
    
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    <div class="recordSaveError">
            {!v.returnMsg}
    </div>
</aura:component>

Here's my Lightning Controller:
({
	doInit : function(component, event, helper) {
        var action = component.get("c.executeJob");
        action.setParams({"oppoId": component.get("v.recordId")});
        // Configure response handler
        action.setCallback(this, function(response) {
            var state = response.getState();
            debugger;
            if(component.isValid() && state === "SUCCESS") {
                component.set("v.returnMsg", response.getReturnValue());  
            } else if (state() === “ERROR”){
                var errors = action.getError();
                if (errors) {
                    if (errors[0] && errors[0].message) {
                        cmp.set(“v.message”, errors[0].message);
                    }
                   
                }
            }
        });

		$A.enqueueAction(action);

    },

})

If you have any input on how to approach this, please let me know. Thank you.!
Hi all, 

This is kind of urgent. I'm using a Aura component and trying to pass an ID to a apex code. However, without using the aura, in classic, my code works like a charm. When I try to pass the value via aura, it does not. 

Below is my Aura Controller which is setting the URL. 
myAction : function(component, event, helper) {
        debugger;
		var action = component.get("c.getOpportunity");
        action.setParams({"OppId": component.get("v.recordId")});
        action.setCallback(this, function(response){
            var state = response.getState();
            if(component.isValid() && state == "SUCCESS"){
                var elem = response.getReturnValue();
                var redirectURL = "/apex/SubmitForApproval?id=" + elem.id;
                redirectURL += "&lock=0";
                
                var urlEvent = $A.get("e.force:navigateToURL");
                urlEvent.setParams({
                  "url": redirectURL
                });
                urlEvent.fire();
            } else {
                component.set("v.hasErrors", true);
                
            }
        });
        $A.enqueueAction(action);
	},

Below is my existing Apex code trying to modify:
public without sharing class SubmitForApprovalExtension {
    public Id objId { get; set; }
    public String doLock { get; set; }
    public SubmitForApprovalExtension(){

//below line is where I'm getting the error for objId
        objId = ApexPages.currentPage().getParameters().get('id');
        doLock = Apexpages.currentPage().getParameters().get('lock');
    }
    
-
-
-
-
-

//enabling the Aura controller

@AuraEnabled
    public static Opportunity getOpportunity(String OppId){
        Opportunity opp = [select Id from opportunity where Id =: OppId limit 1];
        return opp;
    }
}

I'm getting error message saying System.StringException: Invalid id: undefined. I have no idea what it means Undefined. When I put in the actualy Id of the record, it works fine.. Just the ApexPages.currentPage() will not work. Please help!!! 
 
Hello, 

I was asked to take a stab at implementing another system with Salesforce which will pull information from Salesforce Opportunity object into their mobile app. Since this is my very first time working with API's, I'm extremely lost on where to start. 

I read bunch of articles and the developer guide to understand the different API's and their use. However, my confusing is on what the first step is, I should be taking.

Problems or task at hand: We are looking at a mobile Timecard application, where users will use the app to login and pull up a Opportunity record (I'm guessing this is just the name of opportunity) and stamp their time to clock in and out of a job. I was provided with their TimeCard SOAP API documentation to take a look at the api's and the library. 

Questions
1. What is the first step should I be doing? (If I'm not wrong, I believe we will also be updating few fields on Opportunity after they have entered their time to clock in or out. If not Oppostunity record, then related object to Opportunity) 
2. What questions should I be asking them (the developer from Timecard app)? 
3. Do I write a webservice, generate Apex WSDL and give it to them? (Assuming data needs to go from Salesforce to their system)
4. I don't have any experience in .NET, do I need to? 
5. Why do I need to look at their API documentation? Are they assuming that I will be writing code on their end? Again, going back what should I be asking them? How does this usually work?
6. What do I do with the WSDL file when they give me their, if they do (steps by steps)? 

As you can tell I have never worked with webservices and api's but I think this is a very good opportunity for me to learn hands on and work with it. Even though it is very short amount of time to soak everything up, I am hoping someone will guide me to the right direction. Also, I do not have any mentor or go to person to ask since I'm the solo Salesforce person working here. SO, I will be needing lots of help. Any guidance will be truly appreciated! 

Thank you. 
Hi I have a custome clone button which will take the user to a visualforce page. However, everytime I try to save the record and open in Edit mode, I noticed the URL still says Clone = 1 even though I speficially assigned an url. Please help. 

Here's the URL :

User-added image

This is after I have saved the record. 

In my Pagerefence I have assigned the new record ID to refresh the page and route user to the correct page. 
pv = new Pagereference('/'+controller.getId() +'/e?&retUrl=%2F'+controller.getId())

This should save the record and take the user to edit page of the newly created record. However, I see the URL still have the Clone = 1. 

How do I get rid of this? Please help. 
 
Hi all, 

I have two save method, one just redirects to edit page and the other one save and close and returns to newly created record. However, problem is when I clone the record, the url has Clone = 1  https://atirestoration--fullcopy--c.cs13.visual.force.com/apex/BudgetSheet?clone=1  <--- This one

How do I redirect the record to erase that clone and take the user to edit page. Also, when I do that, Save and close or when I Cancel, page does not return to the main page and shows me a blank page. Please help me out. I'm so lost in this. I'm assuming it is not assigning the controller Id to redirect to the newly created record. How do I solve this? 

Here are my two methods:
public PageReference quickSaveBudget(){   
        
        PageReference pv;
        ID OldBudgetID = ExtCon.getID();
        
        ExtCon.save();
        
        try{
                   
            // Check if it is Save or Clone.
            // If CLone the execute clone line item
           // Then redirect to new budget ID.  
            
            if(OldBudgetID != ExtCon.getID()){
            
                cloneLineItem(ExtCon.getID(), OldBudgetID);     
                
                pv = new Pagereference('/'+ExtCon.getID());
                pv.setRedirect(true);

            }
            Else{
              saveLineItem(ExtCon.getID());
              getBudgetLineItem();
              pv = null;
            }

            system.debug('What is the pv returning? '+ pv);
            
            
        }catch(Exception e){
            ApexPages.Message emsg = new ApexPages.Message(ApexPages.Severity.ERROR,e.getMessage());    
            ApexPages.addMessage(emsg);
        }        
        
        return pv;
    }
    
    public pageReference saveBudget(){
     
        PageReference pv;
        
        ID OldBudgetID = ExtCon.getID();
        ExtCon.save();
        
        try{
                   
            // Check if it is Save or Clone.
            // If CLone the execute clone line item
           // Then redirect to new budget ID.  
            
            if(OldBudgetID != ExtCon.getID()){
            
                cloneLineItem(ExtCon.getID(), OldBudgetID);
                      
            }                
            else
                saveLineItem(ExtCon.getID());
                
            system.debug('What is the pv returning? '+ pv);
            
        } catch(exception e){
            ApexPages.Message ErrorMsg = new ApexPages.Message(ApexPages.Severity.ERROR,e.getMessage());
            ApexPages.addMessage(ErrorMsg);
        }
        
         //pv = ExtCon.view();
        pv = new Pagereference('/'+ExtCon.getID());
        pv.setRedirect(true);
       
        return pv;
    }

 
Hi, I'm trying to figure out why does the line item do not save when I click on Quick Save. It should redict to edit page which it does, however it does not save the input value. I'm assuming it retrieving all the old date and inserting. However, how do I compare the line Item and see if there are new values and save it over?

Here's the code snippet below:
 
public void cloneLineItem(ID budgetId, ID oldBudget){

            System.debug('this is inside the clone method');
        // copy over the line items - ONLY INCLUDE THE FIELDS YOU WANT TO CLONE
         List<Budget_Line_Item__c> items = new List<Budget_Line_Item__c>();
         
         for (Budget_Line_Item__c LI : [Select Id, Name, Actual_Costs__c, Allocations__c, Budget__c, Burden__c, Estimated_Completion_Date__c, Fees__c, Gross_Profit__c, 
                                         In_House_Hours__c, In_House_Rate__c, In_House_Total__c, Materials__c, Profit__c, Revenue__c, Start_Date__c, Subcontractor__c, Subcontractor_bid__c, 
                                             Trade__c, Trade_Option__c FROM Budget_Line_Item__c WHERE Budget__c = :oldBudget]) {  
              Budget_Line_Item__c newLI = LI.clone(false);
              newLI.Budget__c = budgetId;
              items.add(newLI);

         }
         insert items;       

         BudgetRecord = (Budget__c)this.ExtCon.getRecord();  
    }
    
    public PageReference quickSaveBudget(){   
        
        PageReference pv;

       //ExtCon is the controller and saving the previous id for checking whether the record is a clone.

        ID OldBudgetID = ExtCon.getID();
        
        ExtCon.save();
        
        try{
 
            
            if(OldBudgetID != ExtCon.getID()){
            
                cloneLineItem(ExtCon.getID(), OldBudgetID);     
            }

              saveLineItem(ExtCon.getID());
              getBudgetLineItem();

            system.debug('What is the pv returning? '+ pv);
            
            
        }catch(Exception e){
            ApexPages.Message emsg = new ApexPages.Message(ApexPages.Severity.ERROR,e.getMessage());    
            ApexPages.addMessage(emsg);
        }        
        
        return pv;
    }
    
    public pageReference saveBudget(){
     
        PageReference pv;
        

        ID OldBudgetID = ExtCon.getID();
        ExtCon.save();
        
        try{
                   
            // Check if it is Save or Clone.
            // If CLone the execute clone line item
           // Then redirect to new budget ID.  
            
            if(OldBudgetID != ExtCon.getID()){
            
                cloneLineItem(ExtCon.getID(), OldBudgetID);
                      
            }                
                saveLineItem(ExtCon.getID());
                
            system.debug('What is the pv returning? '+ pv);
            
        } catch(exception e){
            ApexPages.Message ErrorMsg = new ApexPages.Message(ApexPages.Severity.ERROR,e.getMessage());
            ApexPages.addMessage(ErrorMsg);
        }
        
        pv = ExtCon.view();
       
        return pv;
    }
    
    public void saveLineItem(ID budgetID){ 
  
        List<Budget_Line_Item__c> saveBudgetLineItem = new List<Budget_Line_Item__c>();

        //try{
        for(WrapperClass wc:wrapBudget){
           if(wc.budget.Trade__c != null && wc.budget.Trade__c != ''){
                if(wc.budget.id==null){
                    wc.budget.Budget__c = budgetID;
                } 

                saveBudgetLineItem.add(wc.budget);
            } 

        } 
        
        upsert saveBudgetLineItem;
        if(delBudgetLineItem!=null){
            delete delBudgetLineItem;
        }
        
        BudgetRecord = (Budget__c)this.ExtCon.getRecord(); 

    }
     
    public class WrapperClass{
        public Integer indx{get;set;}
        public Budget_Line_Item__c budget{get;set;}    
        public WrapperClass(Integer indx,Budget_Line_Item__c budget){
            this.indx = indx;
            this.budget = budget;
        }
    
    }

 
Hi, 

I'm wrecking my brain on how to achieve this. So I'm trying to run a child object from an apportunity. Child object may have multiple records. If so I need to find the previous entered record by comparing the recently created date with previous one. 

I'm writing an after insert trigger to achieve this. However, how do I find the previous records? I'm also trying to avoid nested for loops. So far this is what I have and giving me error: BudgetTrigger: execution of AfterInsert caused by: System.FinalException: Record is read-only Class.BudgetPreviousVersion.VersionUpdate: line 27
 
public without sharing class BudgetPreviousVersion {

    public static TriggerStatus__c cfg = TriggerConfig.raw;

    public static void VersionUpdate(list<Budget__c> budget){
        
        Set<Id> opportunityIds = new Set<Id>(); 
                
        for(Budget__c b: budget){
        
            if(b.Job__c != null){ 
                opportunityIds.add(b.Job__c);
                
            }
        }
        
        Map<ID, Budget__c> budmap = new Map<ID, Budget__c>();
        
        for(Budget__c b:[Select id, previous_version__c, CreatedDate From Budget__c WHERE job__c IN: opportunityIds order by createddate DESC limit 1]){
            
            budmap.put(b.id, b);                                 
        }
        
  List<budget__c> listb = new list<budget__c>();
       for(Budget__c b: budget){
           if(budmap.containskey(b.id)){
                 b.previous_version__c = true;                  

           }
           listb.add(b);
        }//for loop for each customer survey and assign them to customer survey.  */
         upsert listb;
    } 
}

Notice that I tried to upsert because upon searching it says the value is not yet commited. So upserting should update the value, right? How can I re-write this so I can avoid the nested loop? 
 
Hi I have a pageblocktable which displays a row of input fields, which could also consist of text and formula fields. My issue is that, I have a button call Save (quicksave), which saves the displayed record and their child record (rows displayed) without having to refresh the entire page. 

How do I refresh the value or get the value to populate when I click Save? It is calculating all the rollup summery fields but not the formula fields inside the pageblocktable.
 User-added image

The value only shows up if I hit Save and Close (redirects to the actual master record), then hit edit button again. 
<apex:page standardController="Budget__c"  extensions="BudgetController" standardStylesheets="true" >

    <apex:sectionHeader subtitle="{!Budget__c.Name}" title="Budget Form"/>

    <apex:form id="BudgetForm">
        <apex:pageMessages id="messages"/>
        <apex:pageBlock title="Budget Edit" mode="edit" id="BudgetpageBlock">
            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!quickSaveBudget}" rerender="messages,BudgetForm, LineItem, test" />
                <apex:commandButton value="Save & Close" action="{!saveBudget}"/>
                <apex:commandButton value="Cancel" action="{!cancel}"/>
            </apex:pageBlockButtons>
 <apex:actionRegion immediate="true">                  
                <apex:pageBlockSection title="Budget Line Item" >
                   
                    <apex:pageBlockTable value="{!wrapBudget}" var="wrap" id="LineItem">
                        <apex:column >
                            <apex:commandButton value="Delete" action="{!deleteLineItem}" reRender="LineItem">
                                <apex:param name="wrpIndxParam" value="{!wrap.indx}" assignTo="{!count}"/>
                            </apex:commandbutton>
                        </apex:column>
                        <apex:column headerValue="Trade">
                            <apex:inputField value="{!wrap.budget.Trade__c}"/>
                        </apex:column>
                        <apex:column headerValue="Revenue">
                            <apex:inputField value="{!wrap.budget.Revenue__c}"/>
                        </apex:column>
                        <apex:column headerValue="Allocations">
                        <apex:inputField value="{!wrap.budget.Allocations__c}"/>
                    </apex:column>

</apex:pageBlockTable>
</apex:pageBlockSection>
 </apex:actionRegion>

......................................................................

 </apex:pageBlock>
    </apex:form>
</apex:page>

Here is a snippet of what the visualforce looks like. Please let me know if this can be achievable. 

Thank you. 
Hi friends, 

Once again I'm asking for help because I can't seem to figure out where the bug is. 

I have a contact field on opportunity and when there is an active campaign assigned to that contact, I want to take that id and update the primary campaign source field on opportunity. So that Campaign Influence will populate. 

However, even setting CampaignID on opportunity does not set primary campaign source. 

This is the  AFTER trigger calling the apex class:
else if (Trigger.IsInsert)
            {
    
            	for(Opportunity opp : trigger.new)
            	{
            		OppId.add(opp.id);
            	}
            	
            	CampaignAssignmentToJob.CampaignAssignmentToJob(OppId);
            }
            // otherwise it is update
            else
            {
            	for(Opportunity opp : trigger.new)
            	{
            		OppId.add(opp.id);
            	}
            	
            	CampaignAssignmentToJob.CampaignAssignmentToJob(OppID);
            }

Here's the class: 
public with sharing class CampaignAssignmentToJob {
	
	@future
	public static void CampaignAssignmentToJob (list<ID> Opty)
	{ 
		List<Opportunity> opps = [select id from Opportunity where id IN: Opty];
		
		
		Set<ID> ContactID = new Set<ID>();

		
		for(Opportunity opp: Opps)
		{
			if(opp.Contact__c != null)
			{
				ContactID.add(opp.Contact__c);

			}
		}
		
		System.debug('This is the ContactID:::::::::::::::::::::::::::::::::::::::::::::::::::' + ContactID);
		

		list <CampaignMember> CampMember = new list<CampaignMember>();
		
		if(!ContactID.isempty())
		{
			CampMember = new list<CampaignMember>([Select Id, contactid, CampaignID From CampaignMember where contactid IN: ContactID order by CreatedDate ASC]);
			
		}
		
		map<Id, List<CampaignMember>> cmMap = new map<Id, List<CampaignMember>>();
		
		//map <String, String> CampaignMap = new map<String, String>();
		
		for(CampaignMember member: CampMember)
		{
			List<CampaignMember> workList = cmMap.containsKey(member.ContactId) ? cmMap.get(member.ContactId) : new List<CampaignMember>();
			workList.add(member);
			cmMap.put(member.contactId,workList);

		}
		
		System.debug('This is the CampMember:::::::::::::::::::::::::::::::::::::::::::::::::::' + CampMember);

		list<Opportunity> OppList = new list<Opportunity>();
		
		for(Opportunity opp: Opps)
		{
			if (cmMap.containsKey(opp.contact__c))
			{
				for (CampaignMember cm: cmMap.get(opp.contact__c))
				{
					opp.CampaignID = cm.CampaignID;
					OppList.add(opp);
				}
			}
		}
		

		
		if(!OppList.isEmpty())
		{
			update OppList;	
		}
		
	
	}

}

Is there any other way I can set the primary campaign source?  I'm not getting any error, just the field isn't up dating. 
Hi friends, 

I'm recieving this error message and don't know why it is an invalid field. Can someone please help me? 
//fetch ContactID from opportunity in a set<ID> ContactID

if(!ContactID.isempty())
		{
			CampMember = new list<CampaignMember>([Select Id, CampaignID From CampaignMember where contactid IN: ContactID]);
		}

CampaignMember CM = new CampaignMember();


if(opportunity.contact__c != null)
{
   CM = (CampaignMember)CampMember[0].get(opportunity.contact__c);
}

The last line CM assignment is giving me the error. Why is this an invalid field? 
 
Hi all, 

I'm having trouble writing unit test to cover my Conditional statement. Especially checking the map. 
 
Set<id> office = new set<id>();

for(Opportunity opp: OppMap.values())
		{
			if(opp.Office2__c == null)
			{
				continue;
			}
            else
            {
                OfficeID.add(opp.Office2__c);
            }
		}
I'm having trouble for checking the Office__c == null statement and the setID. 

Also, 
Opportunity opp = OppMap.get(suv.Opportunity__c);
         	if(opp == null)
         	{
         		continue; 
         	}
         	else
            {
            	 //field update from Opportunity to Customer Survey
		         
            	//check if the id is found
                office__c off = offices.get(OppMap.get(suvey.Opportunity__c).Office2__c);

                if(off == null)
                {
                    continue;
                }
                else 
                {
                    //field update from Office__c to Customer Survey. 
                }

My unit test is not going through the conditional statement. 
 
public static TestMethod void TestforNullOFfice()
    {
        Office__c office = addOffice();  
                
        Opportunity opp = AddOpportunity(office);
        
        Customer_Survey__c survey = runTestOnCustomerSurvey(opp);
        
        
        List<Customer_Survey__c> surveys = new List<Customer_Survey__c>();
        surveys.add(survey);
        
       //calls the main class to run the rest. 
        CustomerSurveyFieldUpdate.CustomerSurveyFieldUpdate(surveys);
    }
public static Customer_Survey__c runTestOnCustomerSurvey(opp)
{
        //created the customer survey with opp.
}

public static Opportunity AddOpportunity(office)
{
    Opportunity opp = new opportunity();
    opp.office2__c = office;
    
   insert opp;
   
  return opp;
}

public static Office__c addOffice() 
{
    Office__c office = new Office__c();

    //assigns roles
     office.branch_manager = 'some user.id'; 
    
   insert office;
   
  return office;
}

What exactly am I missing? Please any pointer would help. I'm not sure how exactly go around checking the map. Also, for future reference, is there a way to check the if and else condition to write better unit test, please kindly share your tips. 

Thank you. 



 
Hi, 

So I know Campaign Influence API isn't available to apex and visualforce page. So my turn around work was fetch the contact id from opportunity, Then run a query of all the campaign memeber where it matches the id, fetch the ID of the campaign. Then add to the Primary Campign on the opportunity. 

However, I'm not really expert at Maps so here's where I'm a little stuck. Looking at the code, how do I fetch the ID of the campaign and added to the Opportunity list? 

 
Set<ID> ContactIds = new Set<ID>();
        for (Opportunity rec: workingOpps)
        {
            if(rec.Contact__c != null)
            {
                ContactIds.add(rec.Contact__c);
            }
        }
        
        Map<ID, CampaignMember> CampaignMember = new Map<id, CampaignMember>(
            [select 
            id, CampaignId from CampaignMember where ContactId in: ContactIds]);
        
        for (Opportunity opp : workingOpps)
        {
            //Check if the map is empty
            Boolean empty = CampaignMember.isEmpty();
            if(empty)
            {
                continue;
            }
            //check if the campaign id exit in the job. 
            
            //CampaignMember memberID = CampaignMember.get(????????????);
            
            
            //opp.Campaign = CampaignMember.Campaign.id;
        }

Any help or ideas are appreciated. Thanks 
Hi, 

I have unchecked "View Setup and Configuration" from the system permission for all the profile except the System admin. It is still showing up when I log in as one of the user. 

How do I hide that? 
Hi all, 

I'm not sure who used process builder yet. But I'm trying to populate a field call branch manager on opportunity if a field Office is populated. The process updates my branch manager and populates it on creation. However, when I close a record and save it, regardless of office was changed or not and regardless of branch manager is populated with previous value or not, process builder does not update the record. 

Is there a way to fix it or does it only work on creation and on edit? 

I spoke to support and they said to use formula critera and add

OR(
ISCHANGED( [Opportunity].Office2__c ),
ISCHANGED( [Opportunity].Division__c ),

AND(
ISNEW(),
OR(
NOT(ISBLANK( [Opportunity].Office2__c )),
NOT(ISBLANK( [Opportunity].Division__c )))
))


I have added those and re-tested. Still does not seem to work. 
Hi I wrote an apex extension class to auto assign the record type looking at a parent record. However I'm getting Null value on assertion. Can someone please help me? I have been wrecking my brain and can't figure it out. 
 
//I'm inserting the parent - testJobObj
insert testJobObj; 
       
       ID jobId = testJobObj.Id;
       //System.currentPageReference().getParameters().put('retURL', jobId);
        
        Work_order__c order = new Work_Order__c(Job_Number__c = testJobObj.id);
       
       insert order;
       
       ApexPages.StandardController sc = new ApexPages.standardController(order);
       WorkOrderRedirectExtension test = new WorkOrderRedirectExtension(sc);
       System.currentPageReference().getParameters().put('retURL','/'+ jobId);
       pageReference pr = test.redirect();

       System.assertEquals(system.currentPageReference().getParameters().get('RecordType'), '012Q00000000kxB' );

    }


}
Then here's my apex extension method: 
 
public PageReference redirect(){
        
        Id parentId = ApexPages.currentPage().getParameters().get('retURL').substring(1,16);
        system.debug('This is the parent Id Im recieving' + parentId);
        String param = '';
		List<job__c> job = [select id, division__c from Job__c where id =: ParentId limit 10];
        for(job__c j: job){
            if(j.Division__c == 'Contents'){
                param = getParameters()+'&RecordType=012Q00000000kxB';
                System.debug('This is the job division' + j.Division__c);
            }
            else if(j.Division__c == 'Structure'){
                param = getParameters()+'&RecordType=012Q00000000l42';
                System.debug('This is the job division' + j.Division__c);
            }
            else
                param = getParameters()+'&RecordType=012Q00000000kxG';
        }
        
        system.debug('RecordType' + param);
        String prefix = Work_Order__c.SObjectType.getDescribe().getKeyPrefix();
        Pagereference page = new PageReference('/'+prefix+'/e?nooverride=1&'+param); 
        Page.setRedirect(true);
        return page;
    }



 
Hello, 

I was asked to take a stab at implementing another system with Salesforce which will pull information from Salesforce Opportunity object into their mobile app. Since this is my very first time working with API's, I'm extremely lost on where to start. 

I read bunch of articles and the developer guide to understand the different API's and their use. However, my confusing is on what the first step is, I should be taking.

Problems or task at hand: We are looking at a mobile Timecard application, where users will use the app to login and pull up a Opportunity record (I'm guessing this is just the name of opportunity) and stamp their time to clock in and out of a job. I was provided with their TimeCard SOAP API documentation to take a look at the api's and the library. 

Questions
1. What is the first step should I be doing? (If I'm not wrong, I believe we will also be updating few fields on Opportunity after they have entered their time to clock in or out. If not Oppostunity record, then related object to Opportunity) 
2. What questions should I be asking them (the developer from Timecard app)? 
3. Do I write a webservice, generate Apex WSDL and give it to them? (Assuming data needs to go from Salesforce to their system)
4. I don't have any experience in .NET, do I need to? 
5. Why do I need to look at their API documentation? Are they assuming that I will be writing code on their end? Again, going back what should I be asking them? How does this usually work?
6. What do I do with the WSDL file when they give me their, if they do (steps by steps)? 

As you can tell I have never worked with webservices and api's but I think this is a very good opportunity for me to learn hands on and work with it. Even though it is very short amount of time to soak everything up, I am hoping someone will guide me to the right direction. Also, I do not have any mentor or go to person to ask since I'm the solo Salesforce person working here. SO, I will be needing lots of help. Any guidance will be truly appreciated! 

Thank you. 
Hi, 

I'm wrecking my brain on how to achieve this. So I'm trying to run a child object from an apportunity. Child object may have multiple records. If so I need to find the previous entered record by comparing the recently created date with previous one. 

I'm writing an after insert trigger to achieve this. However, how do I find the previous records? I'm also trying to avoid nested for loops. So far this is what I have and giving me error: BudgetTrigger: execution of AfterInsert caused by: System.FinalException: Record is read-only Class.BudgetPreviousVersion.VersionUpdate: line 27
 
public without sharing class BudgetPreviousVersion {

    public static TriggerStatus__c cfg = TriggerConfig.raw;

    public static void VersionUpdate(list<Budget__c> budget){
        
        Set<Id> opportunityIds = new Set<Id>(); 
                
        for(Budget__c b: budget){
        
            if(b.Job__c != null){ 
                opportunityIds.add(b.Job__c);
                
            }
        }
        
        Map<ID, Budget__c> budmap = new Map<ID, Budget__c>();
        
        for(Budget__c b:[Select id, previous_version__c, CreatedDate From Budget__c WHERE job__c IN: opportunityIds order by createddate DESC limit 1]){
            
            budmap.put(b.id, b);                                 
        }
        
  List<budget__c> listb = new list<budget__c>();
       for(Budget__c b: budget){
           if(budmap.containskey(b.id)){
                 b.previous_version__c = true;                  

           }
           listb.add(b);
        }//for loop for each customer survey and assign them to customer survey.  */
         upsert listb;
    } 
}

Notice that I tried to upsert because upon searching it says the value is not yet commited. So upserting should update the value, right? How can I re-write this so I can avoid the nested loop? 
 
Hi, 

I have a String variable in my controller call ChildQuery. I want to pass a value to the string variable from Visualforce page without any javascript or button. How can that be possible? This value needs to be hidden and auto assign as soon as the visualforce page is opened.  

//set the value of Childquery to "write some string value here like ABCD"  without calling <script></script>
// maybe using these tags below? 

<!-- apex:inputHidden  / -->
<!-- apex:param  / -->
<!-- apex:variable / -->

This is what my class would look like. I'm writing a generic class which would be used by many many different visualforce page. So cannot set the value of the variavle in the controller. It has to pass through the visualforce page so I can throw any page and just call this controller class. 
Class sObject {

public string ChildQuery {get; set;}

    public sObjectController(ApexPages.StandardController controller){
      
        system.debug('THIS IS THE VALUE I'M GETTING:' + ChildQuery);

    }

}



 
Hi all, 

This is kind of urgent. I'm using a Aura component and trying to pass an ID to a apex code. However, without using the aura, in classic, my code works like a charm. When I try to pass the value via aura, it does not. 

Below is my Aura Controller which is setting the URL. 
myAction : function(component, event, helper) {
        debugger;
		var action = component.get("c.getOpportunity");
        action.setParams({"OppId": component.get("v.recordId")});
        action.setCallback(this, function(response){
            var state = response.getState();
            if(component.isValid() && state == "SUCCESS"){
                var elem = response.getReturnValue();
                var redirectURL = "/apex/SubmitForApproval?id=" + elem.id;
                redirectURL += "&lock=0";
                
                var urlEvent = $A.get("e.force:navigateToURL");
                urlEvent.setParams({
                  "url": redirectURL
                });
                urlEvent.fire();
            } else {
                component.set("v.hasErrors", true);
                
            }
        });
        $A.enqueueAction(action);
	},

Below is my existing Apex code trying to modify:
public without sharing class SubmitForApprovalExtension {
    public Id objId { get; set; }
    public String doLock { get; set; }
    public SubmitForApprovalExtension(){

//below line is where I'm getting the error for objId
        objId = ApexPages.currentPage().getParameters().get('id');
        doLock = Apexpages.currentPage().getParameters().get('lock');
    }
    
-
-
-
-
-

//enabling the Aura controller

@AuraEnabled
    public static Opportunity getOpportunity(String OppId){
        Opportunity opp = [select Id from opportunity where Id =: OppId limit 1];
        return opp;
    }
}

I'm getting error message saying System.StringException: Invalid id: undefined. I have no idea what it means Undefined. When I put in the actualy Id of the record, it works fine.. Just the ApexPages.currentPage() will not work. Please help!!! 
 
Hello, 

I was asked to take a stab at implementing another system with Salesforce which will pull information from Salesforce Opportunity object into their mobile app. Since this is my very first time working with API's, I'm extremely lost on where to start. 

I read bunch of articles and the developer guide to understand the different API's and their use. However, my confusing is on what the first step is, I should be taking.

Problems or task at hand: We are looking at a mobile Timecard application, where users will use the app to login and pull up a Opportunity record (I'm guessing this is just the name of opportunity) and stamp their time to clock in and out of a job. I was provided with their TimeCard SOAP API documentation to take a look at the api's and the library. 

Questions
1. What is the first step should I be doing? (If I'm not wrong, I believe we will also be updating few fields on Opportunity after they have entered their time to clock in or out. If not Oppostunity record, then related object to Opportunity) 
2. What questions should I be asking them (the developer from Timecard app)? 
3. Do I write a webservice, generate Apex WSDL and give it to them? (Assuming data needs to go from Salesforce to their system)
4. I don't have any experience in .NET, do I need to? 
5. Why do I need to look at their API documentation? Are they assuming that I will be writing code on their end? Again, going back what should I be asking them? How does this usually work?
6. What do I do with the WSDL file when they give me their, if they do (steps by steps)? 

As you can tell I have never worked with webservices and api's but I think this is a very good opportunity for me to learn hands on and work with it. Even though it is very short amount of time to soak everything up, I am hoping someone will guide me to the right direction. Also, I do not have any mentor or go to person to ask since I'm the solo Salesforce person working here. SO, I will be needing lots of help. Any guidance will be truly appreciated! 

Thank you. 
Hi all, 

I have two save method, one just redirects to edit page and the other one save and close and returns to newly created record. However, problem is when I clone the record, the url has Clone = 1  https://atirestoration--fullcopy--c.cs13.visual.force.com/apex/BudgetSheet?clone=1  <--- This one

How do I redirect the record to erase that clone and take the user to edit page. Also, when I do that, Save and close or when I Cancel, page does not return to the main page and shows me a blank page. Please help me out. I'm so lost in this. I'm assuming it is not assigning the controller Id to redirect to the newly created record. How do I solve this? 

Here are my two methods:
public PageReference quickSaveBudget(){   
        
        PageReference pv;
        ID OldBudgetID = ExtCon.getID();
        
        ExtCon.save();
        
        try{
                   
            // Check if it is Save or Clone.
            // If CLone the execute clone line item
           // Then redirect to new budget ID.  
            
            if(OldBudgetID != ExtCon.getID()){
            
                cloneLineItem(ExtCon.getID(), OldBudgetID);     
                
                pv = new Pagereference('/'+ExtCon.getID());
                pv.setRedirect(true);

            }
            Else{
              saveLineItem(ExtCon.getID());
              getBudgetLineItem();
              pv = null;
            }

            system.debug('What is the pv returning? '+ pv);
            
            
        }catch(Exception e){
            ApexPages.Message emsg = new ApexPages.Message(ApexPages.Severity.ERROR,e.getMessage());    
            ApexPages.addMessage(emsg);
        }        
        
        return pv;
    }
    
    public pageReference saveBudget(){
     
        PageReference pv;
        
        ID OldBudgetID = ExtCon.getID();
        ExtCon.save();
        
        try{
                   
            // Check if it is Save or Clone.
            // If CLone the execute clone line item
           // Then redirect to new budget ID.  
            
            if(OldBudgetID != ExtCon.getID()){
            
                cloneLineItem(ExtCon.getID(), OldBudgetID);
                      
            }                
            else
                saveLineItem(ExtCon.getID());
                
            system.debug('What is the pv returning? '+ pv);
            
        } catch(exception e){
            ApexPages.Message ErrorMsg = new ApexPages.Message(ApexPages.Severity.ERROR,e.getMessage());
            ApexPages.addMessage(ErrorMsg);
        }
        
         //pv = ExtCon.view();
        pv = new Pagereference('/'+ExtCon.getID());
        pv.setRedirect(true);
       
        return pv;
    }

 
Hi I have a pageblocktable which displays a row of input fields, which could also consist of text and formula fields. My issue is that, I have a button call Save (quicksave), which saves the displayed record and their child record (rows displayed) without having to refresh the entire page. 

How do I refresh the value or get the value to populate when I click Save? It is calculating all the rollup summery fields but not the formula fields inside the pageblocktable.
 User-added image

The value only shows up if I hit Save and Close (redirects to the actual master record), then hit edit button again. 
<apex:page standardController="Budget__c"  extensions="BudgetController" standardStylesheets="true" >

    <apex:sectionHeader subtitle="{!Budget__c.Name}" title="Budget Form"/>

    <apex:form id="BudgetForm">
        <apex:pageMessages id="messages"/>
        <apex:pageBlock title="Budget Edit" mode="edit" id="BudgetpageBlock">
            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!quickSaveBudget}" rerender="messages,BudgetForm, LineItem, test" />
                <apex:commandButton value="Save & Close" action="{!saveBudget}"/>
                <apex:commandButton value="Cancel" action="{!cancel}"/>
            </apex:pageBlockButtons>
 <apex:actionRegion immediate="true">                  
                <apex:pageBlockSection title="Budget Line Item" >
                   
                    <apex:pageBlockTable value="{!wrapBudget}" var="wrap" id="LineItem">
                        <apex:column >
                            <apex:commandButton value="Delete" action="{!deleteLineItem}" reRender="LineItem">
                                <apex:param name="wrpIndxParam" value="{!wrap.indx}" assignTo="{!count}"/>
                            </apex:commandbutton>
                        </apex:column>
                        <apex:column headerValue="Trade">
                            <apex:inputField value="{!wrap.budget.Trade__c}"/>
                        </apex:column>
                        <apex:column headerValue="Revenue">
                            <apex:inputField value="{!wrap.budget.Revenue__c}"/>
                        </apex:column>
                        <apex:column headerValue="Allocations">
                        <apex:inputField value="{!wrap.budget.Allocations__c}"/>
                    </apex:column>

</apex:pageBlockTable>
</apex:pageBlockSection>
 </apex:actionRegion>

......................................................................

 </apex:pageBlock>
    </apex:form>
</apex:page>

Here is a snippet of what the visualforce looks like. Please let me know if this can be achievable. 

Thank you. 
Hi friends, 

Once again I'm asking for help because I can't seem to figure out where the bug is. 

I have a contact field on opportunity and when there is an active campaign assigned to that contact, I want to take that id and update the primary campaign source field on opportunity. So that Campaign Influence will populate. 

However, even setting CampaignID on opportunity does not set primary campaign source. 

This is the  AFTER trigger calling the apex class:
else if (Trigger.IsInsert)
            {
    
            	for(Opportunity opp : trigger.new)
            	{
            		OppId.add(opp.id);
            	}
            	
            	CampaignAssignmentToJob.CampaignAssignmentToJob(OppId);
            }
            // otherwise it is update
            else
            {
            	for(Opportunity opp : trigger.new)
            	{
            		OppId.add(opp.id);
            	}
            	
            	CampaignAssignmentToJob.CampaignAssignmentToJob(OppID);
            }

Here's the class: 
public with sharing class CampaignAssignmentToJob {
	
	@future
	public static void CampaignAssignmentToJob (list<ID> Opty)
	{ 
		List<Opportunity> opps = [select id from Opportunity where id IN: Opty];
		
		
		Set<ID> ContactID = new Set<ID>();

		
		for(Opportunity opp: Opps)
		{
			if(opp.Contact__c != null)
			{
				ContactID.add(opp.Contact__c);

			}
		}
		
		System.debug('This is the ContactID:::::::::::::::::::::::::::::::::::::::::::::::::::' + ContactID);
		

		list <CampaignMember> CampMember = new list<CampaignMember>();
		
		if(!ContactID.isempty())
		{
			CampMember = new list<CampaignMember>([Select Id, contactid, CampaignID From CampaignMember where contactid IN: ContactID order by CreatedDate ASC]);
			
		}
		
		map<Id, List<CampaignMember>> cmMap = new map<Id, List<CampaignMember>>();
		
		//map <String, String> CampaignMap = new map<String, String>();
		
		for(CampaignMember member: CampMember)
		{
			List<CampaignMember> workList = cmMap.containsKey(member.ContactId) ? cmMap.get(member.ContactId) : new List<CampaignMember>();
			workList.add(member);
			cmMap.put(member.contactId,workList);

		}
		
		System.debug('This is the CampMember:::::::::::::::::::::::::::::::::::::::::::::::::::' + CampMember);

		list<Opportunity> OppList = new list<Opportunity>();
		
		for(Opportunity opp: Opps)
		{
			if (cmMap.containsKey(opp.contact__c))
			{
				for (CampaignMember cm: cmMap.get(opp.contact__c))
				{
					opp.CampaignID = cm.CampaignID;
					OppList.add(opp);
				}
			}
		}
		

		
		if(!OppList.isEmpty())
		{
			update OppList;	
		}
		
	
	}

}

Is there any other way I can set the primary campaign source?  I'm not getting any error, just the field isn't up dating. 
Hi friends, 

I'm recieving this error message and don't know why it is an invalid field. Can someone please help me? 
//fetch ContactID from opportunity in a set<ID> ContactID

if(!ContactID.isempty())
		{
			CampMember = new list<CampaignMember>([Select Id, CampaignID From CampaignMember where contactid IN: ContactID]);
		}

CampaignMember CM = new CampaignMember();


if(opportunity.contact__c != null)
{
   CM = (CampaignMember)CampMember[0].get(opportunity.contact__c);
}

The last line CM assignment is giving me the error. Why is this an invalid field? 
 
Hi all, 

I'm having trouble writing unit test to cover my Conditional statement. Especially checking the map. 
 
Set<id> office = new set<id>();

for(Opportunity opp: OppMap.values())
		{
			if(opp.Office2__c == null)
			{
				continue;
			}
            else
            {
                OfficeID.add(opp.Office2__c);
            }
		}
I'm having trouble for checking the Office__c == null statement and the setID. 

Also, 
Opportunity opp = OppMap.get(suv.Opportunity__c);
         	if(opp == null)
         	{
         		continue; 
         	}
         	else
            {
            	 //field update from Opportunity to Customer Survey
		         
            	//check if the id is found
                office__c off = offices.get(OppMap.get(suvey.Opportunity__c).Office2__c);

                if(off == null)
                {
                    continue;
                }
                else 
                {
                    //field update from Office__c to Customer Survey. 
                }

My unit test is not going through the conditional statement. 
 
public static TestMethod void TestforNullOFfice()
    {
        Office__c office = addOffice();  
                
        Opportunity opp = AddOpportunity(office);
        
        Customer_Survey__c survey = runTestOnCustomerSurvey(opp);
        
        
        List<Customer_Survey__c> surveys = new List<Customer_Survey__c>();
        surveys.add(survey);
        
       //calls the main class to run the rest. 
        CustomerSurveyFieldUpdate.CustomerSurveyFieldUpdate(surveys);
    }
public static Customer_Survey__c runTestOnCustomerSurvey(opp)
{
        //created the customer survey with opp.
}

public static Opportunity AddOpportunity(office)
{
    Opportunity opp = new opportunity();
    opp.office2__c = office;
    
   insert opp;
   
  return opp;
}

public static Office__c addOffice() 
{
    Office__c office = new Office__c();

    //assigns roles
     office.branch_manager = 'some user.id'; 
    
   insert office;
   
  return office;
}

What exactly am I missing? Please any pointer would help. I'm not sure how exactly go around checking the map. Also, for future reference, is there a way to check the if and else condition to write better unit test, please kindly share your tips. 

Thank you. 



 
Hi all, 

I'm not sure who used process builder yet. But I'm trying to populate a field call branch manager on opportunity if a field Office is populated. The process updates my branch manager and populates it on creation. However, when I close a record and save it, regardless of office was changed or not and regardless of branch manager is populated with previous value or not, process builder does not update the record. 

Is there a way to fix it or does it only work on creation and on edit? 

I spoke to support and they said to use formula critera and add

OR(
ISCHANGED( [Opportunity].Office2__c ),
ISCHANGED( [Opportunity].Division__c ),

AND(
ISNEW(),
OR(
NOT(ISBLANK( [Opportunity].Office2__c )),
NOT(ISBLANK( [Opportunity].Division__c )))
))


I have added those and re-tested. Still does not seem to work. 
Hi I wrote an apex extension class to auto assign the record type looking at a parent record. However I'm getting Null value on assertion. Can someone please help me? I have been wrecking my brain and can't figure it out. 
 
//I'm inserting the parent - testJobObj
insert testJobObj; 
       
       ID jobId = testJobObj.Id;
       //System.currentPageReference().getParameters().put('retURL', jobId);
        
        Work_order__c order = new Work_Order__c(Job_Number__c = testJobObj.id);
       
       insert order;
       
       ApexPages.StandardController sc = new ApexPages.standardController(order);
       WorkOrderRedirectExtension test = new WorkOrderRedirectExtension(sc);
       System.currentPageReference().getParameters().put('retURL','/'+ jobId);
       pageReference pr = test.redirect();

       System.assertEquals(system.currentPageReference().getParameters().get('RecordType'), '012Q00000000kxB' );

    }


}
Then here's my apex extension method: 
 
public PageReference redirect(){
        
        Id parentId = ApexPages.currentPage().getParameters().get('retURL').substring(1,16);
        system.debug('This is the parent Id Im recieving' + parentId);
        String param = '';
		List<job__c> job = [select id, division__c from Job__c where id =: ParentId limit 10];
        for(job__c j: job){
            if(j.Division__c == 'Contents'){
                param = getParameters()+'&RecordType=012Q00000000kxB';
                System.debug('This is the job division' + j.Division__c);
            }
            else if(j.Division__c == 'Structure'){
                param = getParameters()+'&RecordType=012Q00000000l42';
                System.debug('This is the job division' + j.Division__c);
            }
            else
                param = getParameters()+'&RecordType=012Q00000000kxG';
        }
        
        system.debug('RecordType' + param);
        String prefix = Work_Order__c.SObjectType.getDescribe().getKeyPrefix();
        Pagereference page = new PageReference('/'+prefix+'/e?nooverride=1&'+param); 
        Page.setRedirect(true);
        return page;
    }



 
Hi, I have this piece of code running. I'm trying to set the record type of a child object by using condition to look at a field value of parent.

Eg. Job division = content, Recordtype of work order = restoration.
       job division = other, Recordtype of work order = environmenta.

I have this in my pagereference but the parameter does not run correctly. I'm not sure how else should I be defining the parameters. 
 
public PageReference redirect(){
        
        String prefix = Work_Order__c.SObjectType.getDescribe().getKeyPrefix();
        String param = getParameters()+'&RecordType={!IF(Ispickval(Job_Number__c.Division__c,content),012Q00000000kxB,012Q00000000kxG)}';
        return new PageReference('/'+prefix+'/e?nooverride=1&'+param); 
    }

This is the error I'm getting:

Unable to Access Page
The value of the "id" parameter contains a character that is not allowed or the value exceeds the maximum allowed length. Remove the character from the parameter value or reduce the value length and resubmit. If the error still persists, report it to our Customer Support team. Provide the URL of the page you were requesting as well as any other related information. 

 
Hi folks, 

I have a quick request. How would I go about chaning a record type of a child object depending on what the value of a picklist field on a parent object. 

This should be done by Visualforce page because I'm trying to overwrite the New button on the child object. So that users won't have to sleect the record type. 

Please help, this is a little urgent. 
Hi I have written a trigger to update a field "Approved By" on a custom object. However, due to record locked by Approval process, the trigger had to be before trigger. Is there a way I can fetch the ID of the user who actually approved the process? 

processinstance[0].WorkItems[0].ActorId will return the first or the last userid depending on the index. I cannot figure out how to fetch who is actual approver. 

Also ActorID only returns an ID of a queue if the process assigns it to a queue. Not the userID. How can I get the the user ID.. PLEASEE PLEASEEE HELP!! 

I need to release this code within 2-3 days so I'm in dier need of help right now!
Hi I have written a trigger that will update a field on Account when the child record is created or the first child records (on Account) will get updated. However, my test class is failing on the de-refence a null object and I'm getting 91% coverage. how? 

Error Message:

System.DmlException: Upsert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, NewJobTimeStampOnAccount: execution of AfterInsert

caused by: System.NullPointerException: Attempt to de-reference a null object

Trigger.NewJobTimeStampOnAccount: line 22, column 1: []

Trigger:
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
trigger NewJobTimeStampOnAccount on Job__c (after insert, after update) {

  Map<ID, Account> parentAcct = new Map<ID, Account>(); //Making it a map instead of list for easier lookup
  List<Id> listIds = new List<Id>();
 
if(trigger.isInsert || trigger.isUpdate){
  for (Job__c childObj : Trigger.new){
    listIds.add(childObj.Account__c);
  }
}
  //Populate the map. Also make sure you select the field you want to update, amount
  //The child relationship is more likely called jobs__r (not job__r) but check
  //You only need to select the child jobs if you are going to do something for example checking whether the job in the trigger is the latest
  parentAcct = new Map<Id, Account>([SELECT id, New_Job_Start_Date__c, (SELECT ID, Date_Time_Taken__c FROM Jobs__r) FROM Account WHERE ID IN :listIds]);
 
  List<Job__c> i = [select id from Job__c where Account__c in :listIds order by Date_Time_Taken__c ASC limit 5];

  for (Job__c job: Trigger.new){
     if(i[0].id == job.id)
     {
        Account myParentAcct = parentAcct.get(job.Account__c);
        myParentAcct.New_Job_Start_Date__c = job.Date_Time_Taken__c;
       
     }
  }
  update parentAcct.values();

}

Test class:

@isTest
private class NewJobTimeStampOnAccount_Test {

    static testmethod void test_trigger(){
     
        Job__c job = new Job__c(Job_Name__c = 'Roy,Semira tes', Date_Time_Taken__c = datetime.now(), contact__c = '003S000000m4qD5', Account__c = '001S000000gq5Dp', Project_manager__c = '00570000002rgiK', name = '6##-##-02206', Stage__c = 'Qualification', Status__c = 'Opportunity', Office__c = 'Chicago', Lead_Source__c = 'Agent', Job_class__c = 'Apartment', County__c = 'Orange', City_of_LA__c = 'No');
      
        upsert job;
      
    }
}
When you start off with a Contact that's associated with one or more campaigns, when you create a new Opportunity from the related list on the Contact the Campagin Influence is set on the Opportunity, and one of the campaign members is chosen as the Primary Campaign Source. I have Apex code that creates the Opportunity and links in the Opportunity Contact Role. When I create the Opportunity through the code, the Primary Campaign Source is NOT set. I know you can set the CampaignId on the Opportunity and that will make the Campaign the Primary Campaign Source, but it will not make the Campaign Member the Primary. I know there's not really a way through code to set the Primary Source on the campaign member, but does anyone know why it does not set a Primary Source when I don't set the CampaignId on the Opportunity creation?

Hi All

 

I am working with the Approval Process and have the following question:  Is there a way to report on the "Actual Approver" field (located in the Approval History section) if not is there a way to transfer the value from the Actual Approval field to a field on the object.

 

TIA

 

David