• Phillip Southern
  • SMARTIE
  • 605 Points
  • Member since 2013
  • clicks 2 code


  • Chatter
    Feed
  • 18
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 165
    Replies
Hello, I'm trying to create a trigger that updates a CampaignMember status and create a case to a lead in a web to case action, i created a hidden field that comes filled with the campaign Id,but when my triggers is fired it only updates the status of my CampaignMember and don't create the case to the Lead. Someone could help me with that?
trigger ai_WebToCaseLead on Case (after insert) {


List<CampaignMember> listCm = [SELECT Id,Lead.Email,CampaignId FROM CampaignMember WHERE CampaignId = '701190000001F5l'];

    for(Case caso : Trigger.new){
        System.debug('caso');
        for(CampaignMember cm : listCm){
                    System.debug('caso');

            if(cm.Lead.Email == caso.SuppliedEmail && caso.ChaveCampanha__c == '701190000001F5l'){
                cm.Status = 'Respondido';
   				caso.ParentId = cm.Lead.Id;
                update cm;
                update caso;
                System.debug(cm);
                System.debug(caso);
            }
        }
    }
}



Regards!
Lucas
Hi, I'm new to the world of developing and trying to learn all the syntax, have read a few books on the topic and browsed around for the info but can't find a quick reference of these very basic questions.  

I've gotten by largely by modding existing free GitHub and forum provided code.

But I've still got basic questions regarding what some of these symbols mean and when they are used.

For example:  the ! sign.

The $ sign (I think is to call universal components, as I've used it in the $User context).

The " should convey direct text, but I'm not so sure.

The { and the ( are pretty interchangeable to me, but I know that that can't be right.  When would you use one over the other?

Any other advice much appreciated.
I've got a front-end, back-end page that takes user input and creates and then displays a SOQL query.  In this the date order is displaying descending.  Can we get it to display in ascending order?  Better yet, if they could click the title of the display column to order it by that critieria that would be even better.
Hi Folks,
          Can anyone tell me how to display the 10 values in two column?
my code:
       <apex:pageBlock title="My Contact">

        <apex:pageBlockTable value="{!account.Contacts}" var="item" columns="2">

            <apex:column value="{!item.name}"/>

        </apex:pageBlockTable>


The above code display in  one coumn


Please Help!
Hello, i need to modify the code of an existing trigger in our salesforce. the original trigger was coded by a firm we a no longer dealing with.

basically, the trigger automatically changes the stage of the opportunity depending on actions the sales rep are doing (calling, sending emails, receiving prospects in the sales office)

so here's the deal.

existing code :

if (e.Type != null && e.Type == 'Walk-In')
      walkin++;

id like to modify it so the walkin+++ occurs not only when there is a event named ''walk-in", but also for all those containing "Meeting".

the event type "walk-in" is for when a prospect visits a sales office unnanounced.  we added 1st meeting, 2nd meeting, 3rd meeting, 4th+ meeting as event types to log when the prospects visits after they have talked to a sales rep.

so i guess something like

If (e.Type !=null && (e.Type == ‘Walk-In’ || e.Type.contains(‘Meeting’))
Walkin++

??

thanks for the help, i'm new at apex development and it's a bit overwhelmong at first.

since i'm modifying an existing trigger, can i just change it in the dev console and save?

thank you!
Hi, Can any ne tell me
"how to write a query to find the most recent SystemModStamp on object".
On a custom object, I have created a simple javascript button which creates tasks on the click.

{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}

var t = new sforce.SObject("Task");

t.OwnerId = '{!Custome_Object.User_Id}';
t.Subject = "Task With Jscript";
...
t.What = '{!Custome_Object.Id}'; 

var result = sforce.connection.create([t]);

if(result[0].getBoolean("success")){
window.location = "/" + result[0].id;
}else{
alert('Could not create record '+result);
}

I can't figure out how to set the t.What (Related To) field. I get the following error:

{errors:{message:'The external foreign key reference does not reference a valid entity: What', statusCode:'INVALID_FIELD', }, id:null, success:'false', }

My searches tuned out nothing. :(
Any suggestion would be appreciated.

btw, I don't want to use the URL hack or the URLFOR function.

Thank you
  • March 30, 2014
  • Like
  • 0
I wrote the following trigger to pull the Max date from a child record.  The problem is, it is not pulling the Max value it's pulling the value of the last child record entered.  I tried using the Select Max(Enrollment_Status_Date__c) but I receved an error, Malformed Query - Only root queries support aggregate expressions.

Any ideas how to get the max value?

<pre>
trigger Update_Latest_Enrollment_Date_v02 on SD_Mbr_Enroll_Cycles__c (after insert, after update) {

Map<id,SD_Member__C> SDM = New Map<id,SD_Member__C>();
List<id> sdId = New List<id>();

For (SD_Mbr_Enroll_Cycles__c sdec : Trigger.new) {
        sdid.add(sdec.SD_Member_Stakeholders__c);}

System.debug(sdid);

SDM =  New Map<id,SD_Member__C>([Select Id, Name, Enrollment_Date_Latest_OnTrak__c,
                                (select SD_Member_Stakeholders__c, Enrollment_Status__c, Enrollment_Status_Date__c
                                          From SD_Mbr_Enroll_Cycles__r
                                          Where Use_Me__c = True
                                          and Enrollment_Status__c = 'Enrolled'
                                          ORDER BY Enrollment_Status_Date__c DESC LIMIT 1)
                                From  SD_Member__c
                                Where ID IN : sdid ]);
                           
For(SD_Mbr_Enroll_Cycles__c EC: Trigger.new){
    SD_member__c sd1 = sdm.get(ec.SD_Member_Stakeholders__c);
    sd1.Enrollment_Date_Latest_OnTrak__c = ec.Enrollment_Status_Date__c;
   
    System.debug(ec.Enrollment_Status_Date__c);
}

Update sdm.values();

}
</pre>
I need to replace a 10 digit string - a phone number with a format like (123) 456-7890 because unforutnately, the DB a total mess.

I can do it in PHP like this:
$data = '1234567890';

if(  preg_match( '/^\d(\d{3})(\d{3})(\d{4})$/', $data,  $matches ) )
{
    $result = '('.$matches[1] . ') ' .$matches[2] . '-' . $matches[3];
    return $result;
}
Which works fine in PHP, but't I can't seem to translate it to APEX. Any help would be apprecieated.
 
hi have 5 record types, by using one particular record type i was created a record , after saving the record my record type is changing to some other record type in detail page ,,why this is happenning..
    i dont have any workflow or trigger active for this
Hi There,

I am attemping to write a simple Apex Trigger that updates the owner ID based on a picklist value.

Picklist contains the aliases of our account managers and based on this I want to update the owner ID on insert.

Reason for this is because we have administrators entering opportunities and it will save them time rather than having to create the record then change it owner.

I have the following:

trigger UpdateOwnerID on Opportunity (after insert) {
       
    for (Opportunity objOpportunity : Trigger.new)
    {
        if (objOpportunity.Owner.Alias <> objOpportunity.Account_Manager__c)               
        {
            objOpportunity.Owner.Alias = objOpportunity.Account_Manager__c;
        }
    }
   
   

}

But I keep getting this error:

Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger UpdateOwnerID caused an unexpected exception, contact your administrator: UpdateOwnerID: execution of AfterInsert caused by: System.NullPointerException: Attempt to de-reference a null object: Trigger.UpdateOwnerID: line 7, column 1

Any help would be appreciated.

Thanks
I'm drawing a blank on how to use the standard {!Save} function in my visualforce on the command button. Basically after I click Save I want to redirect the page into a new page.

Here is my VF page code

<apex:page standardController="Lead" recordSetVar="leads" id="thePage" showHeader="true" sidebar="false" extensions="extContactApprovalPage" >
 
  <apex:form >
        <apex:pageBlock >
            <apex:pageBlockTable value="{!leads}" var="l">
                <apex:column >
                    <apex:outputField value="{!l.Name}"/>
                    <apex:facet name="header">Registrant Name</apex:facet>
                </apex:column>
               
                <apex:column >
                    <apex:outputField value="{!l.Approve_Picklist__c}"/>
                    <apex:facet name="header">Approve Picklist</apex:facet>
                </apex:column>
                <apex:column >
                    <apex:outputField value="{!l.Approve_Checkbox__c}"/>
                    <apex:facet name="header">Approve Checkbox</apex:facet>
                </apex:column>
               
              <apex:inlineEditSupport event="onClick" showOnEdit="saveButton, cancelButton"/>
             
          </apex:pageBlockTable>
          <apex:pageBlockButtons >
                <!--<apex:commandButton value="Edit" action="{!save}" id="editButton" />-->
                <apex:commandButton value="Save" action="{!save}" id="saveButton" reRender="none" />
                <apex:commandButton value="Cancel" action="{!cancel}" id="cancelButton" />
            </apex:pageBlockButtons>
      </apex:pageBlock>
 
  </apex:form>
  <!-- Begin Default Content REMOVE THIS -->
  <h1>Congratulations</h1>
  This is your new Page: ContactApprovalPage
  <!-- End Default Content REMOVE THIS -->
</apex:page>

and here is my extension:

public class extContactApprovalPage {

    public extContactApprovalPage(ApexPages.StandardSetController controller) {
      
    }
   
    public PageReference save(){
       
        
        PageReference reRend = new PageReference('/003');
        return reRend;
    }

}

Any assistance would be great thanks.
Hello. We have Professional Edition.  Trying to create an error when an opportunity stage is dead that you have to pick a reason why from a picklist.  That part I got... now trying to limit it to 2 departments which is another picklist.  Can't seem to get it to work.

This validation rule works as is. Does not limit department. Only requires we pick from reason lost/dead picklist if opportunity stage is dead/lost.
AND (
  OR (
     ISPICKVAL( StageName, "Closed Lost"),
     ISPICKVAL( StageName, "Dead")),
ISPICKVAL(  Reason_Lost_or_Dead_2__c , ""))

Tried adding department picklist to this and it doesn't work the way it should.  Networks and Distribution need to follow the validation rule, the others don't need to worry about it.  It's times like this I wish I had Enterprise. 
AND(
   ISPICKVAL(  Reason_Lost_or_Dead_2__c , ""),
AND(
OR(
  ISPICKVAL( CCI_Division_Region__c ,"CCI Networks"),
  ISPICKVAL( CCI_Division_Region__c ,"CCI Distribution"),
AND(
OR (
     ISPICKVAL( StageName, "Closed Lost")),
     ISPICKVAL( StageName, "Dead")))))

Any assistance is appreciated. Thank you.
I would like to create a custom visualforce page for creating a new task. Scenario: user clicks a button on the Activities related list on the parent object. That button launches a VF force page with both standard fields and custom fields for the Task. User populates those fields, then clicks Save. 

I've tried all sorts of things hobbled together from research online, but so far, no luck. 

(I'm a newbie at VF and apex)

Here's my current VF Page code:

<apex:page standardController="Task" extensions="extension_task">
<apex:form >
<apex:pageBlock mode="edit">
<apex:pageblockButtons >
<apex:commandButton value="Save" action="{!save}" />
</apex:pageblockButtons>
        <apex:pageBlockSection title="Quick Edits" columns="1">
            <apex:inputField value="{!Task.Whatid}"/>
            <apex:inputField value="{!Task.Subject}"/>
            <apex:inputField value="{!Task.Representative__c}"/>
            <apex:inputField value="{!Task.Category__c}"/>
            <apex:inputField value="{!Task.Comments__c}" style="width:400px; height:200px"/>
            <apex:inputField value="{!Task.Perceived_Call_Value__c}"/>
            <apex:inputField value="{!Task.Referred_To__c}"/>
            <apex:inputField value="{!Task.Interaction__c}"/>
        </apex:pageBlockSection>
    </apex:pageBlock>
</apex:form>

</apex:page>


Here's the apex class extension:

public class extension_task{

    Task task = new Task();
   
    public extension_task(ApexPages.StandardController controller) {
      this.task = (Task)controller.getRecord();  
    }

}

**************************
I think a problem is that Task cannot be used as a StandardController. I tried setting the StandardController="ACA_Member__c", but that gives me an error (Error: Unknown property 'ACA_Member__cStandardController.Task'). It seems I should be able to use my custom object with standardController based on this page (http://www.salesforce.com/us/developer/docs/pages/Content/pages_controller_std_associate.htm).

Thanks any advance for any help!
Account and a Contact have look up to a City object. When i change the city name in one record the changes must reflect in both objects. can i create workflow in this case. how can i do it can any one please help me out
I have my standard controller as Contact.

The below comes up with 'Error: Invalid field ShippingAddress for SObject Account'

<apex:outputtext Value="Address: {!Contact.account.ShippingAddress}"/> 

But when i use a custom field such as NOC__c instead of ShippingAddress it works fine!!

Please help
Hey there,

I have recently added a cancel button to a record creation page running with an extension. The extension currently is used for saving and cloning, I placed a cancel method into the extension, but I am not sure how to test for it. My test code tests every one of my custom object save and clone buttons, how do I add a test for a cancel method.

My extension with new method Added highlighted:

public class extSaveSerButton {

    public Service__c ser {get;set;}
   
    public extSaveSerButton(ApexPages.StandardController controller) {
  
        this.ser = (Service__c)controller.getRecord();

    }
   
   
    Public PageReference saveDestinyService(){
   


    if(System.currentPageReference().getParameters().get('clone') == '1'){

        //Set record id to null

        ser.Id = null;

    }
   
        insert ser;
        // Send the user to the detail page for the new account.
       PageReference pageRef= new PageReference('/apex/DestinyAccount?id='+ser.account__c+'&Sfdc.override=1');
        pageRef.getParameters().put('tab','Destiny Services');
        return pageRef;
   
    }
   
    Public PageReference cancelDestinyService(){
    PageReference pageRef = new PageReference('/apex/DestinyAccount?id='+ser.account__c+'&Sfdc.override=1');
    pageRef.getParameters().put('tab','Destiny Services');
    return pageRef;

   
    }

}

and my test class with relevent section highlighted:

@isTest
private class TestExtSaveButton {

static testMethod void TestExtSaveButton(){
        //Based on your code and what you give me, Fact Finder is a child of the Account and when you //attach fact finder it needs to be reference into an account.

// create a test account that will be use to reference the Fact Finder Record

Account acc = new Account(Name = 'Test Account');
insert acc;

//Now lets create Fact Finder record that will be reference for the Standard Account
        Fact_Finder__c facTest = new Fact_Finder__c(Account__c = acc.id);
       
        //call the apepages stad controller
        Apexpages.Standardcontroller stdFac = new Apexpages.Standardcontroller(facTest);

//now call the class and reference the standardcontroller in the class.
        extSaveButton ext = new extSaveButton(stdFac);

//call the pageReference in the class.
        ext.saveFactFinder();
    }
   
    static testMethod void TestExtSaveProButton(){



Account acc = new Account(Name = 'Test Pro Account');
insert acc;

//Now lets create Destiny Products record that will be reference for the Standard Account
        Destiny_Products__c proTest = new Destiny_Products__c(Account__c = acc.id);
       
        //call the apepages stad controller
        Apexpages.Standardcontroller stdPro = new Apexpages.Standardcontroller(proTest);

//now call the class and reference the standardcontroller in the class.
        extSaveProButton extPro = new extSaveProButton(stdPro);

//call the pageReference in the class.
        extPro.saveDestinyProducts();
}

static testMethod void TestExtSaveSerButton(){



Account acc = new Account(Name = 'Test Ser Account');
insert acc;

//Now lets create Destiny Products record that will be reference for the Standard Account
        Service__c SerTest = new Service__c(Account__c = acc.id);
       
        //call the apepages stad controller
        Apexpages.Standardcontroller stdSer = new Apexpages.Standardcontroller(serTest);

//now call the class and reference the standardcontroller in the class.
        extSaveSerButton extSer = new extSaveSerButton(stdSer);

//call the pageReference in the class.
        extSer.saveDestinyService();
}


static testMethod void TestExtSaveTraButton(){



Account acc = new Account(Name = 'Test Tra Account');
insert acc;

//Now lets create Destiny Products record that will be reference for the Standard Account
        Transaction__c traTest = new Transaction__c(Account__c = acc.id, Date_of_Payment__c = date.today(), Amount__c = 0);
       
        //call the apepages stad controller
        Apexpages.Standardcontroller stdTra = new Apexpages.Standardcontroller(traTest);

//now call the class and reference the standardcontroller in the class.
        extSaveTraButton extTra = new extSaveTraButton(stdTra);

//call the pageReference in the class.
        extTra.saveDestinyTransaction();
}

static testMethod void TestExtSaveComButton(){



Account acc = new Account(Name = 'Test Com Account');
insert acc;

//Now lets create Destiny Products record that will be reference for the Standard Account
        Notes__c comTest = new Notes__c(Account__c = acc.id);
       
        //call the apepages stad controller
        Apexpages.Standardcontroller stdCom = new Apexpages.Standardcontroller(comTest);

//now call the class and reference the standardcontroller in the class.
        extSaveComButton extCom = new extSaveComButton(stdCom);

//call the pageReference in the class.
        extCom.saveComplianceNotes();
}

}

Thank you in advanced for your help
On this module, specifically on the Apex Rest Callout unit, I feel like this following challenge instruction could be misleading.

    •    The 'getAnimalNameById' method must call https://th-apex-http-callout.herokuapp.com/animals/:id, using the ID passed into the method. The method returns the value of the 'name' property (i.e., the animal name).

If someone physically copies that link, removes id but leaves in : then the challenge review will not pass because the request link will post as 
https://th-apex-http-callout.herokuapp.com/animals/:99
instead of the correct 
https://th-apex-http-callout.herokuapp.com/animals/99

The first incorrect link will still perform get for the request, but just blank values in the json response.


 
I have requirement that i have a object with 2 field topic name and topic description. in 1 vf pafe after clicking on topic name i have to show a page where topic name and description will come as chatter feed . i have to show comment and like also.
could any one tell me how to do chatter .
Hi
Actually my scenario is to display the total price,list price,quantity,discount in VF page. I want to perform dynamic operation for those field that is before saving itself i want to display the total price. I tried that in java script but its not working. Can any one help me out to solve this issue.
I want to display like thisUser-added image

Thanks in advance
On this module, specifically on the Apex Rest Callout unit, I feel like this following challenge instruction could be misleading.

    •    The 'getAnimalNameById' method must call https://th-apex-http-callout.herokuapp.com/animals/:id, using the ID passed into the method. The method returns the value of the 'name' property (i.e., the animal name).

If someone physically copies that link, removes id but leaves in : then the challenge review will not pass because the request link will post as 
https://th-apex-http-callout.herokuapp.com/animals/:99
instead of the correct 
https://th-apex-http-callout.herokuapp.com/animals/99

The first incorrect link will still perform get for the request, but just blank values in the json response.


 
Hi Guys ,

I have a Requirement please help me out
I have account with 5 checkbox fields   and contact objects with 5 checkbox fields  ,on contacts their is a vf overrided ,when i check the  checkboxes whenever i insert and updates in  contact then it has to be updated in account with according to checkboxes  automatically?


please help me out!!!

Thanks ,
Ram
Just created a Flow script and button to launch it from the Contact object using a Visualforce page to create new cases for our volunteer hotline case management system. All of it works great, but last night some of the volunteers said they would rather not use the script and just create cases by bypassing the Flow script, which is fine with their manager. So today I tried to create an additional button that would bypass the script. I tried several solutions but each failed to bypass the Flow script, tried a Visualforce approach and URL link based button. Each time they launched the Flow. Anyone have any ideas how I can create an additional button on the Contact page to bypass the Flow script and go directly to creating a new Case? 

Hi,

I have many opportunities named as "opportunity 2015" related to an account.

Example :

- Account A : has one opportunity named "opportunity 2015"
- Account B : has one opportunity named "opportunity 2015"

I want to create a process builder to create an automated opprtunity for those accounts for 2016 :
- Account A : process builder will create an opportunity named "opportunity 2016"
- Account B : process builder will create an opportunity named "opportunity 2016"

Do you know want kind of criteria i can enter to create automated oppotunities for 2016 related to the same account?

Thanks.

I've created an Invocable Method but Im getting a failure

Insert failed. First exception on row 0; first error: CANNOT_EXECUTE_FLOW_TRIGGER, The record couldn’t be saved because it failed to trigger a flow. <br>A flow trigger failed to execute the flow with version ID 301d0000000LHot

Here is the method
    @InvocableMethod(label='Count_Characters_In_Function' description='')
    public static void processType(KeyValueInv[] kvLst){
//some basic code
//even changed to just putting system.debug
}

I've got an inner class which is basic

public class KeyValueInv {
    @InvocableVariable(label='key1' required=true)
    public String key1;
}

I can select everything as normal in the PB but it fails

Please help?
Hi
How to update opportunity field with product custom field (using trigger).

   
Thanks 
Srikanth.
I have a component that we only show on some layouts for an object.  It has a polling function that monitors changes to the object (an object from a managed package). One function of the polling is to refresh the page when some custom field values change.

I need this refresh functionality now on all layouts for this object, but I do not want to display anything on the actual page in the layouts that do not need it.

What I have tried is to put a public boolean on the controller that says whether or not to render the controls. What this does is hide the controls but leaves a large white space on the page where the controls would be. Of course I do not want this space to show.

Here is a simplified version of my page :
 
<apex:component controller="CustomQuoteMetrics" allowDML="true" >
    <apex:form id="customQuoteMetrics">
        <apex:actionPoller action="{!queryQuote}"  rerender="metrics"  interval="90" />
        <apex:outputPanel rendered="{!refreshQuoteNow}">
        <script>
              window.top.location='/{!quoteID}';
        </script>
        </apex:outputPanel>
        <apex:pageBlock id="metrics" rendered="{!showCustomComponent}">
        </apex:pageBlock>
    </apex:form>
</apex:component>

Any ideas on what I could do differently?
I am a (c#, c++, JavaScript...) developer, but have only been writing apex code on the salesforce platform for about 8 months, so I realize I may not be headed in the right direction.
Hello, I'm trying to create a trigger that updates a CampaignMember status and create a case to a lead in a web to case action, i created a hidden field that comes filled with the campaign Id,but when my triggers is fired it only updates the status of my CampaignMember and don't create the case to the Lead. Someone could help me with that?
trigger ai_WebToCaseLead on Case (after insert) {


List<CampaignMember> listCm = [SELECT Id,Lead.Email,CampaignId FROM CampaignMember WHERE CampaignId = '701190000001F5l'];

    for(Case caso : Trigger.new){
        System.debug('caso');
        for(CampaignMember cm : listCm){
                    System.debug('caso');

            if(cm.Lead.Email == caso.SuppliedEmail && caso.ChaveCampanha__c == '701190000001F5l'){
                cm.Status = 'Respondido';
   				caso.ParentId = cm.Lead.Id;
                update cm;
                update caso;
                System.debug(cm);
                System.debug(caso);
            }
        }
    }
}



Regards!
Lucas
Hi All,
We are trying to integrate SFDC with our system and while trying to fetch an information from a field in SFDC through API , the values are getting fetched in 18 digits instead of hte actual name.

The filed which we are trying is called as Projects which should have names like RBC , Royal Bank of Scotland etc but it shows  like this 006w000000XweAaAAJ ( 18 digits)  in my application instead of the actual data.
How do we get this sorted.
Kindly help.
I'm attempting to set the Contact Owner based on the Account Billing Country using a Custom Setting, Lead_Assignment__c, that maps Country to a User Id. When a Contact is created or updated, the trigger pulls the mapped Country and User Id values from the Custom Setting, finds the Billing Country value from the Account associated with the Contact, and sets the Contact Owner with the User Id that correlates with the Country value that matches the Billing Country.

When I run my trigger, the bolded system.debug show that the Contact Owner values is being set correctly (i.e. the User Id is the User Id mapped to the Billing Country in the Custom Setting), but the field is ulitmately not updated with the correct User Id. Based on field history tracking, it does not look like its being updated at all.
Am I missing something on this trigger?

trigger AssignContact on Contact (before insert, before update) {    
    Set<String> accountSet = new Set<String>();
    Set<Id> contactIdSet = new Set<Id>();
    List<Lead_Assignment__c> lstBillingOwner = [Select ID,Country__c, New_Owner_ID__c FROM Lead_Assignment__c];
    Map<String,String> mpCountryOwner = new Map<String,String>();

    for(Lead_Assignment__c l1 :  lstBillingOwner)    {
        mpCountryOwner.put(l1.Country__c, l1.New_Owner_ID__c);
    }    

    Map<Id,User> mpUser = new Map<Id,User>([Select ID FROM User Where ID IN :mpCountryOwner.values()]);
    Set<Id> accIds = new Set<Id>();

    for(Contact con : trigger.new){
        accIds.add(con.AccountId);
    }

    Map<Id,Account> mpAcc = new Map<Id,Account>([Select ID, Name, BillingCountry FROM Account Where ID IN :accIds]);
    for(Contact con : trigger.new){
        Account act = mpAcc.get(con.AccountId);
        
        if(con.AccountId != null && act.BillingCountry != null){
            if(mpCountryOwner.get(act.BillingCountry) != null){
                con.owner = mpUser.get(mpCountryOwner.get(act.BillingCountry) );  
                System.debug('***** - Updating Owner - New Owner - '+con.owner);
            }
        }
    }
 }



 

I want to build a form in which title of next page and name of record should increment by one. i dont know how to save the value in the controller because every time we direct to new vf page. controller value are getting null .

Example to explain situation:

Page1 :
some detail
Button1: Next          Button2: add another house

If you click on Next it redirects to new page and its value should be 1 which is not a problem
IF you click on add another house the next page title should be house 2 and name of record should be house2  and it direct to same page to create new record.


If he clicks again than it should go to house 3 . 
And if he click to next it redirect to another form which starts from 1. 

Can anyone help me how should i approch this ?            

Thanks

Hi, I'm new to the world of developing and trying to learn all the syntax, have read a few books on the topic and browsed around for the info but can't find a quick reference of these very basic questions.  

I've gotten by largely by modding existing free GitHub and forum provided code.

But I've still got basic questions regarding what some of these symbols mean and when they are used.

For example:  the ! sign.

The $ sign (I think is to call universal components, as I've used it in the $User context).

The " should convey direct text, but I'm not so sure.

The { and the ( are pretty interchangeable to me, but I know that that can't be right.  When would you use one over the other?

Any other advice much appreciated.
I am trying to submit a Case using the java API. When I try to save it, I get the following error:

Record Type ID: this ID value isn't valid for the user: 012E000000023tjIAA

Yet when I query the RecordType with SELECT ID, isactive FROM RecordType where sobjecttype = 'Case' and developername='Complaint_Case' and isactive = true it returns me the following:

true 012E000000023tjIAA.

Stepping through the code, I made sure that the correct id is being returns and it is.

What am I missing? Any insight will be greatly appreciated.


Hi All,
I am trying to display opportunity products on the standard case page layout (The case is related to an opportunity using a look-up)
I am getting the error "Content cannot be displayed: List has no rows for assignment to SObject" I am not a developer and any help would be much appreciated in completing this. I'll owe you some beers at Dreamforce :)

Controller Extension
Public With Sharing Class crossObjectOpportunityInfo {
    Public Opportunity o                {get; private set;}
    Public Case              c              {get; private set;}

    Public List<Schema.FieldSetMember> getFields() {
        return SObjectType.OpportunityLineItem.FieldSets.Display_On_Case.getFields();
    }

    Public crossObjectOpportunityInfo(ApexPages.StandardController sc) {
        this.o = [SELECT Id, AccountId FROM Opportunity WHERE RELATED_OPPORTUNITY__C = :sc.getId() LIMIT 1];

        String queryString = 'SELECT Id';
        List<Schema.FieldSetMember> querySet = SObjectType.OpportunityLineItem.FieldSets.Display_On_Case.getFields();
        for(Schema.FieldSetMember f : querySet) {
            queryString += ', '+ f.getFieldPath();
        }

       
            Id cid = [SELECT Id FROM Contact WHERE AccountId = :o.AccountId LIMIT 1].Id;
            queryString += ' FROM Opportunity WHERE id = \''+ cid +'\' LIMIT 1';
    }

}

VF Page
<apex:page standardController="Case" extensions="crossObjectOpportunityInfo">
<apex:pageBlock title="Opportunity Products">
<apex:pageBlockSection columns="1">
<apex:pageBlockTable value="{!Case.Related_Opportunity__c}" var="line">
<apex:column headerValue="Product">

  </apex:column>
  </apex:pageBlockTable>
  </apex:pageBlockSection>
</apex:pageBlock>
</apex:page>
I've got a front-end, back-end page that takes user input and creates and then displays a SOQL query.  In this the date order is displaying descending.  Can we get it to display in ascending order?  Better yet, if they could click the title of the display column to order it by that critieria that would be even better.