• Peter Friberg
  • NEWBIE
  • 155 Points
  • Member since 2014
  • Architect
  • Fluido

  • Chatter
    Feed
  • 5
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 16
    Replies
I am creating a simple trigger to update the Status field if the field 'Last user to view record' equals the Owner ID of the record and the Status currently equals 'New'. The 'Last user to view record' field is a formula which pulls the current Users ID. (So if the User ID matches the Owner ID the status will change to 'Read') What seems to be wrong?
Thanks for your help!
Ryan
trigger Read on Web_Links__c (before update) 
{
OwnerId From Web_Links__c];
    for(Web_Links__c WI : Trigger.new ){
        if(WI.Status__c = 'New'){
            if(WI.Last_user_to_view_record__c = WI.OwnerId){
                WI.Status__c = 'Read';
            }
        }
    }
}

 
HI, 
I am trying to cover the below apex class, but i am not able to get more than 70% of coverage. can you plaese help me how to write a proper test class. Thanks in advance.

apex controller:

public class ContactForAccountEx {
    public string accName {get;set;}
    public List<contact> cons {get;set;}
    public ContactForAccountEx(){
        cons=new List<contact>();
    }
    public void show(){
        List<account> acc=[select id,name,(select id,lastName,firstName,phone from contacts) from account where name=:accName];
        if(acc.size()>0){
            for(account a:acc){
                for(contact c:a.contacts){
                    cons.add(c);
                }
            }
           }
   }
}


My Test class is..

@isTest
private class MyTest {
    private testMethod static void testMe(){
        string str='sakshi';
        test.startTest();
        ContactForAccountEx s=new ContactForAccountEx();
        s.show();
        test.stopTest();
    }
}
Hi, 

I have an array of product SKU's all in one field seprated by commas e.g. SKU42, SKU08, SKU02, SKU12, SKU64

I would like to use a formula to split out the indidvidual SKU's into separte fields. e.g.
  • Text field 1 will just show the first SKU in the array (SKU42)
  • Text field 2 will just show the second SKU in the array (SKU08)
  • Text field 3 will just show the second SKU in the array (SKU02)
  • etc

Is that possible? I can only seem to get it to split out the first SKU at the moment using a formula but I'm struggling with the rest. 

Many thanks,
Alex. 

We have a VisualForce page/form (embedded flow) that is designed to create a scholarship application for our convention. When running the flow internally, there is no error and the scholarship application is created. When running through the form externally (https://convention.acslaw.org/Student_Convention_Scholarship), the following error occurs and no record (scholarship application) is created.

ERROR MESSAGE
An unhandled fault has occurred in this flow
An unhandled fault has occurred while processing the flow. Please contact your system administrator for more information.

The Flow Appliation error email is sent and provides the following for several attempts to fill out the form:

An error occurred at element Create_Student_Convention_Scholarship_Application (FlowRecordCreate).
INSERT --- INSERT FAILED --- ERRORS : (INVALID_CROSS_REFERENCE_KEY) Record Type ID: this ID value isn't valid for the user: 012G0000001QKQHIA4

In the Create Student Convention Scholarship Application flow, the Record Create element includes RecordTypeID = 012G0000001QKQH. This is the Student Convention Scholarship record type in the custom object Application (Application__c).

Here is information received from a flow alert email (I have the full report available):

An error occurred at element Create_Student_Convention_Scholarship_Application (FlowRecordCreate).
INSERT --- INSERT FAILED --- ERRORS : (INVALID_CROSS_REFERENCE_KEY) Record Type ID: this ID value isn't valid for the user: 012G0000001QKQHIA4

...
RECORD CREATE: Create_Student_Convention_Scholarship_Application
Create one Application__c record where:
Alternate_Email__c = {!Alternate_Email} (shannonportia@gmail.com)
Application_Type__c = Student Convention Scholarship
Cell_Phone_Number__c = {!varCellPhone} (2149493703)
Contact__c = {!varContactID} (003G000002YwQbu)
RecordTypeId = 012G0000001QKQH
SCS_ACS_Career_Goals__c = {!ACSCareerGoals} (Being in ACS leadership has helped me meet progressive lawyers in the ACS network, which I think is indispensable help in today's job search.)
SCS_ACS_Chapter_at_School__c = {!ACSChapteratSchool} (Yes)
SCS_ACS_Value_Most__c = {!What_do_you_value_most_about_ACS} (My law school is relatively conservative. Progressive viewpoints are not welcomed by the student body. The best part of our ACS chapter is simply giving progressive students (however few of us) a platform in a somewhat unfriendly environment.)
SCS_Attend_Previous_Student_Convention__c = null
SCS_Chapter_Activity__c = {!ChapterActivity} (Yes, I am president of the Alabama chapter. I plan all of our events and delegate some responsibilities to the other chapter leaders. I am speakers' point of contact at Alabama.)
SCS_Convention_Arrival_Date__c = {!ConventionArrivalNew} (March 30, 2017)
SCS_Convention_Arrival_Time__c = {!Convention_Arrival_Time_New} (4:30 PM)
SCS_Convention_Departure_Date__c = {!Convention_Departure_Date_New} (April 2, 2017)
SCS_Convention_Departure_Time__c = {!Convention_Departure_Time_New} (6:25 AM)
SCS_Departure_City__c = {!DepartureCityNew} (BHM)
SCS_First_Choice_Package__c = {!FirstChoicePackage} (Scholarship Package B: Travel Costs)
SCS_Gender__c = {!varGender} (Female)
SCS_Hosted_Locally__c = {!HostedLocally} (Yes)
SCS_If_Awarded__c = {!IfAwarded} (Yes)
SCS_Lodging_Dates__c = null
SCS_Lodging_Friends_Family__c = {!FriendsandFamily} (Yes)
SCS_Lodging__c = {!Lodging} (No)
SCS_NGL__c = {!ACSNGL} (I plan to apply to become an NGL)
SCS_Pet_Allergies__c = {!PetAllergy} (None)
SCS_School_Assistance_Type__c = {!SchoolAssistanceType} (N/A)
SCS_School_Assistance__c = {!SchoolAssistance} (Yes)
SCS_Smoke_Bother__c = {!Does_smoking_bother_you} (Yes)
SCS_Smoker__c = {!Smoker} (No)
SCS_Special_Circumstances__c = {!SpecialCircumstances} (None)
SCS_Travel_Scholarship_Type__c = {!TravelScholarshipTypeNew} (Airfare; Driving-mileage reimbursement)
SCS_Traveling_Costs__c = {!TravelingCostsNew} ($400)
School__c = {!varSCID} (a0WG000000DPHTVMA5)
Result
Failed to create record.



Any help would be appreciated.
I am attempting to get a checkbox formula field to be TRUE when another field, "Shipping State", does not contain certain states.  I tried the following but it is not seeing each state as a different value.  What could I be missing?  Thanks!
 
NOT(
AND(
Shipping_State__c = ("AL,AR,AZ,CA,CO,CT,DC,DE,FL,GA,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,RI,SC,SD,TN,TX,UT,VA,VT,WA,WI,WV,WY"),
Shipping_State__c = ("?,NA,1,??,0,.")
)
)

Thanks!
Anyone else experiencing a strange behaviour in the Salesforce UI when it comes to date time fields having a time between 00:00 and 01:00 and using a timezone other than GMT? I use CEST.

If I edit a datetime field in the UI and enter:
"2020-01-04 00:30".
I the check the database record, it shows wrong date:
"2020-01-02T22:30:00.000+0000"

That's just a bit more than two hours diff, right? It is two hours AND an extra 24 hours diff = 26 hours!

If I then edit the datetime field in the UI and add another hour and enter:
"2020-01-04 01:30".
I the check the database record, it shows correct date:
"2020-01-03T23:30:00.000+0000"

So if you have a DB record slowly changing 10 minutes at a time every 10 seconds forward over midnight and you keep refreshing the UI, the UI will perform a major jump back in time one full day between 00:00 and 01:00.

What do you think?

 
I am creating a simple trigger to update the Status field if the field 'Last user to view record' equals the Owner ID of the record and the Status currently equals 'New'. The 'Last user to view record' field is a formula which pulls the current Users ID. (So if the User ID matches the Owner ID the status will change to 'Read') What seems to be wrong?
Thanks for your help!
Ryan
trigger Read on Web_Links__c (before update) 
{
OwnerId From Web_Links__c];
    for(Web_Links__c WI : Trigger.new ){
        if(WI.Status__c = 'New'){
            if(WI.Last_user_to_view_record__c = WI.OwnerId){
                WI.Status__c = 'Read';
            }
        }
    }
}

 
I want to see Id as query string parameter in URL of my custom page. How can I get it and set it?
 
  • January 04, 2017
  • Like
  • 0
Hi all,
I have a question, would be happy if you can give me some pointers.
I have third party operation which uploads some documents in dropbox and based on that opportunities are created manually, like 10-15 at a time, depending on how many documents are there. (I would like to automate this if possible)
The person who creates  these opportunities does not have have credentials to promote these opportunities from one stage to next stage, so he is dependent on admin/business analyst to do it. I want to make this automated. I thought of workflow rule based on a criteria on opportunity field Sales company(custom field). This field value is specific for these third party opportunities. So based on that field value edit when the value = "xyz" I can trigger the workflow rule. This seems like a very simplistic solution  Is there any better/professional way to do this? 
This statement works:
        Account acct = (Account)Account.sObjectType.newSObject(null, true);

This one does not. 
        Quote newQuote = (Quote)Quote.sObjectType.newSObject(null, true);

Any ideas
Jquery is not working when we activate the Locker Service in the org. If I try to deactivate my code works fine.
Is there any workaround to include jquery when locker service is enabled.
Requirement: I have a custom lightning component and we are displaying list of records based on custom query.
Now need to download the same records in csv. 
Solution Approach: Trying to provide a button and include jquery.js in component and use jquery functions to read html from component and then download from controller.
Any help will be appreciated.
Below is my code.

Component

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes" access="global" >
    <ltng:require scripts='/resource/jqueryltng' afterScriptsLoaded="{!c.afterScriptsLoaded}"/>
    <br/>
    <label class="slds-form-element__label" for="org">Click on Download Button to Download CSV</label>
    <ui:button aura:id="button" class="slds-button slds-button--brand" press="{!c.getCsv1}">Download CSV</ui:button>
    <br/>
    <div class="slds-grid" aura:id="displayData" id="dataTable">
        <table class="slds-table slds-table--bordered slds-table--cell-buffer">
            <thead>
                <tr class="slds-text-title--caps">
                    <th class="slds-truncate">First Name</th>
                    <th class="slds-truncate">Last Name</th>
                    <th class="slds-truncate">Company</th>
                </tr>
            </thead>
            <tbody>
                <tr class="slds-truncate">
                    <td class="slds-truncate">AAAAA</td>
                    <td class="slds-truncate">YYYYY</td>
                    <td class="slds-truncate">CCCCC</td>
                </tr>
            </tbody>
        </table>
    </div>
</aura:component>

Controller

({
    getCsv : function(component, event, helper) {
            var $rows = $('#dataTable>table').find('tr:has(td)'),
            // Temporary delimiter characters unlikely to be typed by keyboard
            // This is to avoid accidentally splitting the actual contents
            tmpColDelim = String.fromCharCode(11), // vertical tab character
            tmpRowDelim = String.fromCharCode(0), // null character

            // actual delimiter characters for CSV format
            colDelim = '","',
            rowDelim = '"\r\n"',
            //alert(colDelim);
            //alert(rowDelim);
            // Grab text from table into CSV formatted string
            csv = '"' + $rows.map(function (i, row) {
                var $row = $(row),
                    $cols = $row.find('td');

                return $cols.map(function (j, col) {
                    var $col = $(col),
                        text = $col.text();
                    return text;
                    //return text.replace(/"/g, '""'); // escape double quotes
                }).get().join(tmpColDelim);

            }).get().join(tmpRowDelim)
                .split(tmpRowDelim).join(rowDelim)
                .split(tmpColDelim).join(colDelim) + '"',

        // Data URI
        csvData = 'data:application/csv;charset=utf-8,' + encodeURIComponent(csv);
        window.location.href = 'data:text/csv;charset=UTF-8,'+ encodeURIComponent(csv);
        $(this)
            .attr({
            'download': 'filename.csv',
                'href': csv,
                'target': '_blank'
        });;
    },
    afterScriptsLoaded : function(component, event, helper) {
    }
})
  • December 30, 2016
  • Like
  • 0
Hi,

I have a built a workflow to set the value of a fileld 'Commission Start Date' to the date on which the Opportunity is Closed Won.
The evaluation criteria is based on the Stage and the Previous Stage of an Opportunity record. The field should be updated only when the Stage moves from any other value to Closed Won.
But, in a case where there was no change to the Opportunity stage (already Closed Won) but the name of the Account was changed, the workflow is causing the field update and set the Commission Start Date to TODAY (day on which the name of the Account was changed). I am unable to figure out why is this happening.

Can someone please help me with this scenario. Here is a screenshot of my workflow.
Appreciate the help.

User-added image


Thanks!
HI, 
I am trying to cover the below apex class, but i am not able to get more than 70% of coverage. can you plaese help me how to write a proper test class. Thanks in advance.

apex controller:

public class ContactForAccountEx {
    public string accName {get;set;}
    public List<contact> cons {get;set;}
    public ContactForAccountEx(){
        cons=new List<contact>();
    }
    public void show(){
        List<account> acc=[select id,name,(select id,lastName,firstName,phone from contacts) from account where name=:accName];
        if(acc.size()>0){
            for(account a:acc){
                for(contact c:a.contacts){
                    cons.add(c);
                }
            }
           }
   }
}


My Test class is..

@isTest
private class MyTest {
    private testMethod static void testMe(){
        string str='sakshi';
        test.startTest();
        ContactForAccountEx s=new ContactForAccountEx();
        s.show();
        test.stopTest();
    }
}
Hi, 

I have an array of product SKU's all in one field seprated by commas e.g. SKU42, SKU08, SKU02, SKU12, SKU64

I would like to use a formula to split out the indidvidual SKU's into separte fields. e.g.
  • Text field 1 will just show the first SKU in the array (SKU42)
  • Text field 2 will just show the second SKU in the array (SKU08)
  • Text field 3 will just show the second SKU in the array (SKU02)
  • etc

Is that possible? I can only seem to get it to split out the first SKU at the moment using a formula but I'm struggling with the rest. 

Many thanks,
Alex. 

We have a VisualForce page/form (embedded flow) that is designed to create a scholarship application for our convention. When running the flow internally, there is no error and the scholarship application is created. When running through the form externally (https://convention.acslaw.org/Student_Convention_Scholarship), the following error occurs and no record (scholarship application) is created.

ERROR MESSAGE
An unhandled fault has occurred in this flow
An unhandled fault has occurred while processing the flow. Please contact your system administrator for more information.

The Flow Appliation error email is sent and provides the following for several attempts to fill out the form:

An error occurred at element Create_Student_Convention_Scholarship_Application (FlowRecordCreate).
INSERT --- INSERT FAILED --- ERRORS : (INVALID_CROSS_REFERENCE_KEY) Record Type ID: this ID value isn't valid for the user: 012G0000001QKQHIA4

In the Create Student Convention Scholarship Application flow, the Record Create element includes RecordTypeID = 012G0000001QKQH. This is the Student Convention Scholarship record type in the custom object Application (Application__c).

Here is information received from a flow alert email (I have the full report available):

An error occurred at element Create_Student_Convention_Scholarship_Application (FlowRecordCreate).
INSERT --- INSERT FAILED --- ERRORS : (INVALID_CROSS_REFERENCE_KEY) Record Type ID: this ID value isn't valid for the user: 012G0000001QKQHIA4

...
RECORD CREATE: Create_Student_Convention_Scholarship_Application
Create one Application__c record where:
Alternate_Email__c = {!Alternate_Email} (shannonportia@gmail.com)
Application_Type__c = Student Convention Scholarship
Cell_Phone_Number__c = {!varCellPhone} (2149493703)
Contact__c = {!varContactID} (003G000002YwQbu)
RecordTypeId = 012G0000001QKQH
SCS_ACS_Career_Goals__c = {!ACSCareerGoals} (Being in ACS leadership has helped me meet progressive lawyers in the ACS network, which I think is indispensable help in today's job search.)
SCS_ACS_Chapter_at_School__c = {!ACSChapteratSchool} (Yes)
SCS_ACS_Value_Most__c = {!What_do_you_value_most_about_ACS} (My law school is relatively conservative. Progressive viewpoints are not welcomed by the student body. The best part of our ACS chapter is simply giving progressive students (however few of us) a platform in a somewhat unfriendly environment.)
SCS_Attend_Previous_Student_Convention__c = null
SCS_Chapter_Activity__c = {!ChapterActivity} (Yes, I am president of the Alabama chapter. I plan all of our events and delegate some responsibilities to the other chapter leaders. I am speakers' point of contact at Alabama.)
SCS_Convention_Arrival_Date__c = {!ConventionArrivalNew} (March 30, 2017)
SCS_Convention_Arrival_Time__c = {!Convention_Arrival_Time_New} (4:30 PM)
SCS_Convention_Departure_Date__c = {!Convention_Departure_Date_New} (April 2, 2017)
SCS_Convention_Departure_Time__c = {!Convention_Departure_Time_New} (6:25 AM)
SCS_Departure_City__c = {!DepartureCityNew} (BHM)
SCS_First_Choice_Package__c = {!FirstChoicePackage} (Scholarship Package B: Travel Costs)
SCS_Gender__c = {!varGender} (Female)
SCS_Hosted_Locally__c = {!HostedLocally} (Yes)
SCS_If_Awarded__c = {!IfAwarded} (Yes)
SCS_Lodging_Dates__c = null
SCS_Lodging_Friends_Family__c = {!FriendsandFamily} (Yes)
SCS_Lodging__c = {!Lodging} (No)
SCS_NGL__c = {!ACSNGL} (I plan to apply to become an NGL)
SCS_Pet_Allergies__c = {!PetAllergy} (None)
SCS_School_Assistance_Type__c = {!SchoolAssistanceType} (N/A)
SCS_School_Assistance__c = {!SchoolAssistance} (Yes)
SCS_Smoke_Bother__c = {!Does_smoking_bother_you} (Yes)
SCS_Smoker__c = {!Smoker} (No)
SCS_Special_Circumstances__c = {!SpecialCircumstances} (None)
SCS_Travel_Scholarship_Type__c = {!TravelScholarshipTypeNew} (Airfare; Driving-mileage reimbursement)
SCS_Traveling_Costs__c = {!TravelingCostsNew} ($400)
School__c = {!varSCID} (a0WG000000DPHTVMA5)
Result
Failed to create record.



Any help would be appreciated.
I would like to build a report based on the results of an apex script.  I can create the script and populate the custom object no problem.  What I would like to know is how to run the apex script every time the report is generated.  Is this possible or must I schedule the script to run periodically?
I am attempting to get a checkbox formula field to be TRUE when another field, "Shipping State", does not contain certain states.  I tried the following but it is not seeing each state as a different value.  What could I be missing?  Thanks!
 
NOT(
AND(
Shipping_State__c = ("AL,AR,AZ,CA,CO,CT,DC,DE,FL,GA,IA,ID,IL,IN,KS,KY,LA,MA,MD,ME,MI,MN,MO,MS,MT,NC,ND,NE,NH,NJ,NM,NV,NY,OH,OK,OR,PA,RI,SC,SD,TN,TX,UT,VA,VT,WA,WI,WV,WY"),
Shipping_State__c = ("?,NA,1,??,0,.")
)
)

Thanks!
I call the method below from my opportunity's before update trigger.  I'm hitting a too many soql queries error in some cases and when i run the debug log the culprit is this block of code.  I think it is because this thing has a for loop within a for loop that is causing the issue but I'm not sure.  

Anyone see anything in this piece of code that would cause too many soql queries error:
 
public static void updateProductMarket(List<Opportunity> opps) {
        Schema.DescribeFieldResult Pickvalue = Opportunity.Product_Market_s__c.getDescribe();
        List<Schema.PicklistEntry> PickListValue = Pickvalue.getPicklistValues();
        //get a list of all Ids we are updating and add them to oppIds
        set<Id> oppIds = new set<Id>();
        for(Opportunity opp : opps) {
            oppIds.add(opp.Id);
        }
        //get all Opportunity Products for all Opportunities being updated
        List<OpportunityLineItem> olis = [SELECT Product_Market__c, Opportunity.Id FROM OpportunityLineItem WHERE Opportunity.Id in:oppIds];
        for(Opportunity opp : opps) {
            //loop through each line item
            for(OpportunityLineItem oli : olis) {
                if(oli.Opportunity.Id == opp.Id) {
                    //we have a match
                    if(oli.Product_Market__c != null){
                        if(opp.Product_Market_s__c == null) {
                            opp.Product_Market_s__c = oli.Product_Market__c;
                        } else {
                            if(isNewProductMarket(opp.Product_Market_s__c.split(';'), oli.Product_Market__c)){
                                opp.Product_Market_s__c = opp.Product_Market_s__c + ';' + oli.Product_Market__c;
                            }
                        }
                    }
                }
            }
        }
    }

 
Here are my apex controller and visual force page. And the problem is when I click on delete button all values entered in remaining sections are vanished
<apex:page standardController="Contact" extensions="RegFormController"
           title="Devotee Registration Page" showHeader="false" >

<style>
    .body{
    Width:980px;
    }
    .listHoverLinks{
    margin: 5px 6px 15px;
    font-size: 90%;
    text-align: center;
    display: block;
    line-height: 1.5em;
    }
    span.pipe{
    width:14px;
    height:9px;
    }
    .linklet{
    padding-top: 3px;
    padding-right: 0;
    padding-bottom: 6px;
    padding-left: 4px;
    position: relative;
    }
</style>
    <script>
    jQuery.noConflict();
    jQuery(function($){
        $(".buStyle").val($("[id$='buStyle']").val());
        $(".regionStyle").val($("[id$='regionStyle']").val());
        $(".areaStyle").val($("[id$='areaStyle']").val());
        $(".buDescStyle").val($("[id$='buDescStyle']").val());
        $(".chk").click(function() {
            if($(".chk").attr('checked')) {
                $("[id$='sstreet']").val($("[id$='pstreet']").val());
                $("[class^='sauto']").val($("[class^='pauto']").val());
                $('.cityStyle1').val($('.cityStyle').val());
                $('.stateStyle1').val($('.stateStyle').val())
                $('.countryStyle1').val($('.countryStyle').val());
                $("[id$='cityStyle1']").val($("[id$='cityStyle']").val());
                $("[id$='stateStyle1']").val($("[id$='stateStyle']").val());
                $("[id$='pinStyle1']").val($("[id$='pinStyle']").val());
                $("[id$='countryStyle1']").val($("[id$='countryStyle']").val());
                }
           else {
               $("[id$='sstreet']").val("");
               $("[class^='sauto']").val("");
               $('.cityStyle1').val("");
               $('.stateStyle1').val("")
               $('.countryStyle1').val("");
               $("[id$='cityStyle1']").val("");
               $("[id$='stateStyle1']").val("");
               $("[id$='pinStyle1']").val("");
               $("[id$='countryStyle1']").val("");  
                }
           });
           
        });
    
 </script>
    <apex:outputpanel >
        <apex:actionstatus id="actStatusId">
            <apex:facet name="start">
                <div class="waitingSearchDiv"  style="background-color: #DCD6D6;
                       height: 400%;opacity:0.75;width:100%;">
                    <div class="waitingHolder" style="Position: fixed; top:10;Left:0;Right:0;Bottom:0; width: 91px;">
                        <img  src="{!$Resource.loadingicon}" title="Please Wait..." />
                        <span >Fetching info...</span>
                    </div>
                </div>
            </apex:facet>
        </apex:actionstatus>
    </apex:outputpanel>
    <center >
        <apex:form >
            <apex:image url="{!$Resource.YBanner}" />
            <div class="body">
                <apex:pageBlock title="Primary Member Details" mode="edit" >
                    <apex:pageblocksection columns="3" >
                        <apex:inputField value="{!newcon.FirstName}" required="true" />
                        <apex:inputField value="{!newcon.MiddleName__c}"/> 
                        <apex:inputField value="{!newcon.LastName}"/>
                        <apex:pageBlockSectionItem ><apex:outputlabel value="Postal Code & Village"></apex:outputlabel>
                            <apex:outputPanel >
                                <div class = "requiredInput">
                                    <div class = "requiredBlock"></div>
                                    <c:AutocompleteZipcodes labelField="Name" valueField="Id" SObject="Postal_Code__c" 
                                                            targetField="{!newcon.Postal_Code__c}" id="combobox" />
                                    <apex:inputHidden value="{!pinValue}" id="pinStyle"/>
                                </div>
                            </apex:outputPanel>
                        </apex:pageBlockSectionItem>
                        <apex:pageBlockSectionItem >
                            <apex:outputLabel value="Phone"/>
                            <apex:panelGrid columns="2">
                                <apex:inputField value="{!Contact.Ccode__c}"  style="width:30px;" />
                                <apex:inputField value="{!Contact.Phone}"  required="true" style="Width:125px" />
                            </apex:panelGrid>
                        </apex:pageBlockSectionItem>
                        <apex:inputField value="{!Contact.Language__c}" style="Width:173px" />
                        <apex:inputField value="{!Contact.Street_Adress__c}" label="Street Adress" style="Width:168px"/>
                        <apex:inputField value="{!Contact.Adress_Line2__c}" label="Adress Line2" style="Width:168px"/>
                        <apex:pageBlockSectionItem >
                            <apex:outputlabel value="District"></apex:outputlabel>
                            <apex:outputPanel >
                                <apex:inputtext disabled="true" styleClass="cityStyle"  value="{!newcon.District__c}"/>
                                <apex:inputHidden value="{!cityValue}" id="cityStyle"/>
                            </apex:outputPanel>
                        </apex:pageBlockSectionItem>
                        <apex:pageBlockSectionItem >
                            <apex:outputlabel value="State"></apex:outputlabel>
                            <apex:outputPanel >
                                <apex:inputtext disabled="true" styleClass="stateStyle"  value="{!newcon.State__c}"/>
                                <apex:inputHidden value="{!stateValue}" id="stateStyle"/>
                            </apex:outputPanel>
                        </apex:pageBlockSectionItem>
                        <apex:pageBlockSectionItem >
                            <apex:outputlabel value="Country"></apex:outputlabel>
                            <apex:outputPanel > 
                                <apex:inputtext disabled="true" styleClass="countryStyle"   value="{!newcon.Country__c}"/>
                                <apex:inputHidden value="{!countryValue}" id="countryStyle"/>
                            </apex:outputPanel>
                        </apex:pageBlockSectionItem>
                        <apex:inputField value="{!Contact.Email}" />
                        <apex:inputField value="{!Contact.Profession__c}" label="Profession"  />
                        <apex:inputField value="{!Contact.Rasi_Zodiac_Sign__c}"  label="Rasi/Zodiac Sign"  style="Width:175px" />
                        <apex:inputField value="{!Contact.Nakshatram_Birth_Star__c}" label="Nakshatram/Birth Star"  style="Width:175px"  />
                        <apex:inputField value="{!Contact.Gotram__c}"  label="Gotram" />
                        <apex:pageBlockSectionItem ><b>Your Picture (Wearing Datta Vastram)</b>
                        <apex:inputFile value="{!picture}" accept="image/*" /></apex:pageBlockSectionItem> 
                        <apex:inputField value="{!Contact.Do_You_Volunteer__c}"  style="Width:175px" />
                        <apex:inputfield value="{!Contact.Volunteer_skills__c}"  />
                        <apex:outputPanel id="panel">
                            <apex:actionRegion >
                                <apex:outputLabel value="How many additional family members do you like to register?" 
                                                  styleclass="labelCol vfLabelColTextWrap"/>
                                <apex:inputField value="{!Contact.add__c}"  style="Width:175px" >
                                    <apex:actionSupport action="{!addcontacts}"  event="onchange" reRender="additonalContacts"
                                                        status="actStatusId" />
                                </apex:inputField>
                            </apex:actionRegion>
                        </apex:outputPanel>
                    </apex:pageblocksection>
                    
                    
                    <apex:pageBlockSection id="additonalContacts" collapsible="true">
                        <apex:variable value="{!0}" var="x"/>
                        <apex:param value="{!x+1}" />
                        <apex:repeat value="{!newconList}"  var="c"   >
                            <apex:pageBlocksection title="Additional Member {!x+1} "  columns="3" >
                                <apex:inputField value="{!c.cont.FirstName}" required="true"   />
                                <apex:inputField value="{!c.cont.MiddleName__c}"/>
                                <apex:inputField value="{!c.cont.LastName}"/>
                                <apex:inputField value="{!c.cont.Postal_Code__c}" label="Postal Code & Village"/>
                                <apex:pageBlockSectionItem >
                                    <apex:outputLabel value="Phone"/>
                                    <apex:panelGrid columns="2">
                                        <apex:inputField value="{!c.cont.Ccode__c}"  style="width:30px;" />
                                        <apex:inputField value="{!c.cont.Phone}"  required="true" style="Width:125px" />
                                    </apex:panelGrid>
                                </apex:pageBlockSectionItem>
                                <apex:inputField value="{!c.cont.Language__c}" style="Width:173px"  />
                                <apex:inputField value="{!c.cont.Street_Adress__c}" label="Street Adress" style="Width:168px" />
                                <apex:inputField value="{!c.cont.Adress_Line2__c}" label="Adress Line2" style="Width:168px" />
                                <apex:inputField value="{!c.cont.District__c}" label="District" />
                                <apex:inputField value="{!c.cont.State__c}" label="State" />
                                <apex:inputField value="{!c.cont.Country__c}" label="Country" />
                                <apex:inputField value="{!c.cont.Email}" />
                                <apex:inputField value="{!c.cont.Profession__c}" label="Profession" />
                                <apex:inputField value="{!c.cont.Rasi_Zodiac_Sign__c}"  label="Rasi/Zodiac Sign" style="Width:175px"/>
                                <apex:inputField value="{!c.cont.Nakshatram_Birth_Star__c}" label="Nakshatram/Birth Star"  style="Width:175px" />
                                <apex:inputField value="{!c.cont.Gotram__c}"  label="Gotram"/>
                                <apex:pageBlockSectionItem ><b>Your Picture (Wearing Datta Vastram)</b>
                                <apex:inputFile value="{!c.picture}" accept="image/*" /></apex:pageBlockSectionItem>        
                                <apex:inputField value="{!c.cont.Do_You_Volunteer__c}"  style="Width:175px" />
                                <apex:inputfield value="{!c.cont.Volunteer_skills__c}"   />
                                <apex:actionRegion >
                                    <apex:commandButton action="{!deletecon}" value="Delete"
                                                        status="actStatusId" reRender="additonalContacts,panel" >
                                        <apex:param name="rowIndex" value="{!x}" />
                                    </apex:commandButton>
                                </apex:actionRegion>
                                
                            </apex:pageBlocksection>
                            <apex:variable value="{!x+1}" var="x"/>
                        </apex:repeat></apex:pageBlockSection>
                    <apex:pageBlockButtons location="bottom" >
                        <apex:commandButton action="{!save}" value="Submit" />
                        <apex:commandButton action="{!Cancel}" value="Cancel" />
                    </apex:pageBlockButtons>
                </apex:pageBlock>
            </div>
        </apex:form>
    </center>
</apex:page>
 
public with sharing class RegFormController {
    public Contact newCon {get;set;}
    public List<blob> pictureList {get;set;}
    public blob picture {get;set;}
    public String errorMessage {get;set;}
    public boolean add {get;set;}
    public List<contact> conlist {get;set;}
    public List<ContactWrapper> newConList {get;set;}
    public integer TotalMembers {get;set;}
    public integer rowIndex {get;set;}
    public Account a;
    private final Contact image;
    public String pinValue {get;set;}
    public String cityValue {get;set;}
    public String stateValue {get;set;}
    public String countryValue {get;set;}
    public String countyValue {get;set;}
    public String pinValue1 {get;set;}
    private ApexPages.StandardController stdController;
    
    public RegFormController (ApexPages.StandardController stdController) {
        this.image = (Contact)stdController.getRecord();
        this.stdController = stdController;
        conlist = new List<contact>();
        TotalMembers = 0 ;
        rowIndex = 0;
        newConList = new List<ContactWrapper>();
        id id1 = ApexPages.currentPage().getParameters().get('recordtype');
        string s = ApexPages.currentPage().getParameters().get('rTypeName');
        id id2 = Apexpages.currentpage().getparameters().get('id');
        newcon  = (Contact)stdcontroller.getRecord();
        
        
        if(id2 != null) {
            
            newcon= [select name,postal_code__c,MailingPostalcode,MailingCity,State__c,Country__c from contact where id=:id2];
            
        pinValue=  newcon.postal_code__c;
        cityValue= newcon.District__c;
        stateValue=newcon.State__c;
        countryValue =newcon.Country__c ;
    }
}
  
    public void addcontacts() {
       // String s = (String)ApexPages.currentPage().getParameters().get('text');
       // System.debug('debug s '+s);
       System.debug('newcon '+newcon.FirstName);
        if(newcon.add__c != null) 
            TotalMembers = integer.valueOf(newcon.add__c);
        else
        TotalMembers =0;
        newConList.clear();
        if(TotalMembers >0 ) {
            for(Integer i = 1; i <= TotalMembers; i++) {
                ContactWrapper c = new ContactWrapper();
                c.cont.Ccode__c = '+91';
                //c.cont.Postal_code__c = '517325,Madanapalli';
                //c.cont.District__c = 'Chittor';
                //c.cont.State__c ='ANDHRAPRADESH';
                //c.cont.country__c ='INDIA';
                newconlist.add(c);
            }
        }
    }
    public void deletecon() {
        rowIndex = Integer.valueOf(ApexPages.currentPage().getParameters().get('rowIndex'));
        newconlist.remove(rowIndex);
        
        if(newConList.size()>0)
            newcon.add__c = String.Valueof(newConList.size());
        else
            newcon.add__c = null;
            rowIndex = Integer.valueOf(ApexPages.currentPage().getParameters().get('rowIndex'));
        
        if(newConList.size()>0)
            newcon.add__c = String.Valueof(newConList.size());
        else
            newcon.add__c = null;
    }
    public pagereference save() {
        if( newCon.MiddleName__c == null) {
            newCon.MiddleName__c = '';
        }
        a = New Account(Name = newCon.FirstName + ' ' + newCon.MiddleName__c+ ' ' + newCon.LastName ,Phone=newcon.ccode__c+' '+newcon.Phone,
                             postal_code__c= newcon.Postal_Code__c,billingStreet = newcon.Street_Adress__c,
                             BillingState = newcon.State__c, BillingCountry = newcon.Country__c,
                             billingcity=newcon.District__c,recordTypeId = '01241000000rvGd'); 
        pinValue1=  a.postal_code__c;
        insert a;
        newCon.AccountID = a.id;
        insert newCon;
        errorMessage = '';
        try{
            newcon.postal_code__c = pinvalue ; 
            newcon.District__c = cityValue;
            newcon.Country__c = countryValue;
            newcon.State__c = stateValue;
            a.postal_code__c = pinValue1;
            upsert newCon;
            
            if (picture != null) {
                Attachment attachment = new Attachment();
                attachment.body = picture;
                attachment.name = 'image_' + newCon.id + '.jpg';
                attachment.parentid = newCon.id;
                attachment.ContentType = 'application/jpg';
                insert attachment;
                newCon.Picture_Path__c = '/servlet/servlet.FileDownload?file='+ attachment.id;
                update newCon;
            }
        }
        catch(System.Exception ex) {
            errorMessage = ex.getMessage();
            return null;
        }
        for(ContactWrapper cw : newConList) {
            cw.cont.AccountId = a.id;
            insert cw.cont;    
        }
        for(contactWrapper contacts : newconlist) {
            
            try {
                if (contacts.picture!= null) {
                    Attachment attachment = new Attachment();
                    attachment.body = contacts.picture;
                    attachment.name = 'image_' + contacts.cont.id + '.jpg';
                    attachment.parentid = contacts.cont.id;
                    attachment.ContentType = 'application/jpg';
                    insert attachment;
                    contacts.cont.Picture_Path__c = '/servlet/servlet.FileDownload?file='+ attachment.id;
                }
                upsert contacts.cont;
            }
            catch(System.Exception ex) {
                errorMessage = ex.getMessage();
                return null;
            }
        }
        return new pagereference('/apex/Thank_u');
    }
}
Hi All, 

If i have cusotm field "ConAmount" on contact object which hold any number or any currency and i just want to display a sum of that field for all contact on account page. How can i acheive this? Is it possible using workflow if not then please provide a trigger code for the same.