• fundooMental
  • NEWBIE
  • 40 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 42
    Replies

Hi,

We have a requirement where whenever an Account is created in salesforce we are changing the account owner to some "XYZ" user always. This is done through trigger and working fine (in before trigger we are doing this). But now we have requirement that the person who actually initiated the account creation his/her "Default Account Team memebers" should get added to this Account Team. This should be fine too and I think can be achieved through trigger. Now the biggest challenge is, the requirement also says that whenver this person adds/removes/modifies any account team member in his/her default account team it should reflect in all accounts where actually he initiated the account creation. OK fine, I can capture in one custom field that who actually initiated the account creation (as we are changing the account owner to XYZ user always) but how do we track changes to the default account team members? We cannot write triggers or workflows on AccountTeamMember object and UserAccountTeamMember object then how would I capture the changes this user made to his/her account team to be reflected in all accounts this user initiated the creation? Please help.

Please ask questions if I am not clear. Thanks

I have a cutom Object called "Experiment__c". On the record detail page I have Created a button which invokes the below visualforce page
And on this VF page I have created a button and written an extension class. On this extension class I am updating the current record (The record on which the detail page button was clicked to invoke this visualforce page) on the click of the command button.
But it does nothing. What am I doing wrong?

----VF PAGE-------------

<apex:page standardController="Experiment__c" tabstyle="Experiment__c" extensions="ExperimentStandardControllerExtension">
<apex:form >
<apex:pageBlock title="Experiment Edit" tabStyle="Experiment__c" >
<apex:pageBlockSection title="Information" columns="1" >
<apex:commandButton value="Update" action="{!updateRecord}"></apex:commandButton>

<apex:inputField value="{!Experiment__c.Lab_Country__c}"/>
<apex:inputField value="{!Experiment__c.Date_Entered__c}" required="false"/>

</apex:pageBlockSection>
</apex:pageBlock>

---------Controller Extension------------

public class ExperimentStandardControllerExtension {
Experiment__c ex = new Experiment__c();
Id id;

    public ExperimentStandardControllerExtension(ApexPages.StandardController controller) {
     ex = [SELECT Id,Lab_Country__c,Date_Entered__c FROM Experiment__c WHERE Id = :ApexPages.currentPage().getParameters().get('id')];
     system.debug('Experiment LAB=' + ex.Lab_Country__c);                              
    }
   
    public pagereference updateRecord(){
    update ex;
    system.debug('Experiment LAB=' + ex.Lab_Country__c);
    return null;}

}

I am diplaying the value of multiselct picklist as checkboxes and it shows up correctly. The only thing which I am not able to achieve is, I want to display the checkboxes in three columns, like if I have 12 values for multiselect picklist then the checkboxes should show up in 4 coulmns and 3 rows. And in future if I add more values to the multi-select picklist the next checkbox should automatically be shown in the next column.

At present the checkboxes they all show up in 12 rows (for 12 values) and in one column.

The Visualforce code for getting the multi-select picklist value as checkbox is below:

<apex:selectCheckboxes value="{!slctCheckboxes}" id="selctCB" layout="pageDirection" >
<apex:selectOptions value="{!MultiPickNums}" id="selctOPT"></apex:selectOptions>

I don't know what CSS,HTML or JavaScript to apply to achieve it. Please HELP!!

I don't know how exactly to put my question but I will try my best to put it forward.


We know that there is order of VF page execution and few examples are given for GET and POST methods at below link:
http://www.salesforce.com/docs/developer/pages/index_Left.htm#CSHID=pages_controller_lifecycle.htm|StartTopic=Content%2Fpages_controller_lifecycle.htm|SkinName=webhelp


In the link given above, there is "Get Request Example Two" and in that point # 3 , there it says:


"After custom components are created, all assignTo attributes on those custom components are executed. The assignTo method sets selectedValue on the attribute to the value attribute. The value attribute is set to false, so selectedValue is set to false"


Then in the same example, in the point #4 it says:


"Value = {!value}<br/> selectedValue = {!selectedValue}<br/> EditMode = {!EditMode}
This expression occurs in the custom component. Since value is not null, EditMode is set to true. At this point, selectedValue is set to null. Remember, however, that the setter method for EditMode has a side-effect. In this case, the side-effect sets selectedValue to the value attribute on the custom component. Since value is set to false, selectedValue is set to false. This illustrates why you should not use side-effects in your methods. If the evaluation order were different, and the value for selectedValue were determined before the setter for EditMode was evaluated, selectedValue would still be null. Execution order is not guaranteed, and the result for selectedValue could change the next time this page is visited
"
 

Now I don't understand this:
In point # 3 it says that the selected value is false (since for the custom component attribute we passed the value 'false' in the page). Then why does it says in the point #4 that "At this point, selectedValue is set to null" . How there is side effect here then?

Basically if someone can make me explain the point #3 and point#4 clearly in detail. Any reply would be much much appreciated.

Thank you

I was just trying to understand wrapper classes and then happen to see the below code. Understood everything almost but one thing I am not able to understand is; if I select one or two Account records by clicking on the checkbox (and not all account records through the topmost checkbox), then how the value of the Boolean variable "Selected" is becoming True from false for the selected account records?

See the below Visualforce code and controller class:
-----------VF------------------------------
<apex:page controller="wrapperControllerClassExample1" sidebar="false">
    <script type="text/javascript">
        function selectAllCheckboxes(obj,receivedInputID){
            var inputCheckBox = document.getElementsByTagName("input");
            for(var i=0; i<inputCheckBox.length; i++){
                if(inputCheckBox[i].id.indexOf(receivedInputID)!=-1){
                    inputCheckBox[i].checked = obj.checked;
                }
            }
        }
    </script>
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockButtons >
                <apex:commandButton value="Show Selected Accounts" action="{!processSelected}" rerender="table2"/>
            </apex:pageBlockButtons>
 
            <apex:pageblockSection title="All Accounts" collapsible="false" columns="2">
 
                <apex:pageBlockTable value="{!wrapAccountList}" var="accWrap" id="table" title="All Accounts">
                    <apex:column >
                        <apex:facet name="header">
                            <apex:inputCheckbox onclick="selectAllCheckboxes(this,'inputId')"/>
                        </apex:facet>
                        <apex:inputCheckbox value="{!accWrap.selected}" id="inputId"/>
                    </apex:column>
                    <apex:column value="{!accWrap.acc.Name}" />
                    <apex:column value="{!accWrap.acc.BillingState}" />
                    <apex:column value="{!accWrap.acc.Phone}" />
                </apex:pageBlockTable>
 
                <apex:pageBlockTable value="{!selectedAccounts}" var="c" id="table2" title="Selected Accounts">
                    <apex:column value="{!c.Name}" headerValue="Account Name"/>
                    <apex:column value="{!c.BillingState}" headerValue="Billing State"/>
                    <apex:column value="{!c.Phone}" headerValue="Phone"/>
                </apex:pageBlockTable>
 
            </apex:pageblockSection>
        </apex:pageBlock>
    </apex:form>
 
</apex:page>

------------Controller-----------------
public class wrapperControllerClassExample1 {
 
    //Our collection of the class/wrapper objects wrapAccount
    public List<wrapAccount> wrapAccountList {get; set;}
    public List<Account> selectedAccounts{get;set;}
 
    public wrapperControllerClassExample1(){
        if(wrapAccountList == null) {
            wrapAccountList = new List<wrapAccount>();
            for(Account a: [select Id, Name,BillingState, Website, Phone from Account limit 10]) {
                // As each Account is processed we create a new wrapAccount object and add it to the wrapAccountList
                wrapAccountList.add(new wrapAccount(a));
            }
        }
    }
 
    public void processSelected() {
    selectedAccounts = new List<Account>();
 
        for(wrapAccount wrapAccountObj : wrapAccountList) {
            if(wrapAccountObj.selected == true) {
                selectedAccounts.add(wrapAccountObj.acc);
            }
        }
    }
 
    // This is our wrapper/container class. In this example a wrapper class contains both the standard salesforce object Account and a Boolean value
    public class wrapAccount {
        public Account acc {get; set;}
        public Boolean selected {get; set;}
 
        public wrapAccount(Account a) {
            acc = a;
            selected = false;
        }
    }
}

 

I have two salesforce developer accounts and I create a class with web service method in one of the developer org and want other developer org to invoke this class method using the SOAP Web Service. How can I achieve it?

To put it again: How can the web services in one developer org ( or any salesforce org) can be consumed/used/invoked by other developer org?

I am kind of new to web services but needs a heads up like how to get started.

This might sound silly but I need to know the exact context of this.  When we say "When a trigger fires it can process anywhere from 1 to 200 records " Then what does processing means here?

For example I have a trigger which fires on Object A (before insert ) and it inserts 200 records of Object B. So would this insert DML operation also be called record processing?

Hi,

We have a requirement where whenever an Account is created in salesforce we are changing the account owner to some "XYZ" user always. This is done through trigger and working fine (in before trigger we are doing this). But now we have requirement that the person who actually initiated the account creation his/her "Default Account Team memebers" should get added to this Account Team. This should be fine too and I think can be achieved through trigger. Now the biggest challenge is, the requirement also says that whenver this person adds/removes/modifies any account team member in his/her default account team it should reflect in all accounts where actually he initiated the account creation. OK fine, I can capture in one custom field that who actually initiated the account creation (as we are changing the account owner to XYZ user always) but how do we track changes to the default account team members? We cannot write triggers or workflows on AccountTeamMember object and UserAccountTeamMember object then how would I capture the changes this user made to his/her account team to be reflected in all accounts this user initiated the creation? Please help.

Please ask questions if I am not clear. Thanks

Hey all,

I want to implement a component in the sidebar of my home page for searching Contacts and Accounts.  I have a VF page with an associated controller that I want to use for this component (the search functionality is built in there).  However, I am experiencing an issue that I can't see how to fix.  When the search criteria is entered and the search button clicked, the component in the sidebar is what is refreshed with the resulting data, not the main page. 

How can I cause a sidebar component to refresh and display data on the main page?

Thanks!

Adam

I want to create a VisualFroce page having input fields in it. I want this page to enable Guest User to enter new record in Account Object( or any other Object).

I want headStart on how to write code for Save/Search/Edit/Delete Functions on a visulaForce page.
(Assume that i have created required input fields on visualFroce Page)
 
I can do this using Flow but i want to acheive this using VisualForce Page.

Even a link to similar solved question would do.

PS: Salesforce is new to me.

  • February 27, 2015
  • Like
  • 0
I have a cutom Object called "Experiment__c". On the record detail page I have Created a button which invokes the below visualforce page
And on this VF page I have created a button and written an extension class. On this extension class I am updating the current record (The record on which the detail page button was clicked to invoke this visualforce page) on the click of the command button.
But it does nothing. What am I doing wrong?

----VF PAGE-------------

<apex:page standardController="Experiment__c" tabstyle="Experiment__c" extensions="ExperimentStandardControllerExtension">
<apex:form >
<apex:pageBlock title="Experiment Edit" tabStyle="Experiment__c" >
<apex:pageBlockSection title="Information" columns="1" >
<apex:commandButton value="Update" action="{!updateRecord}"></apex:commandButton>

<apex:inputField value="{!Experiment__c.Lab_Country__c}"/>
<apex:inputField value="{!Experiment__c.Date_Entered__c}" required="false"/>

</apex:pageBlockSection>
</apex:pageBlock>

---------Controller Extension------------

public class ExperimentStandardControllerExtension {
Experiment__c ex = new Experiment__c();
Id id;

    public ExperimentStandardControllerExtension(ApexPages.StandardController controller) {
     ex = [SELECT Id,Lab_Country__c,Date_Entered__c FROM Experiment__c WHERE Id = :ApexPages.currentPage().getParameters().get('id')];
     system.debug('Experiment LAB=' + ex.Lab_Country__c);                              
    }
   
    public pagereference updateRecord(){
    update ex;
    system.debug('Experiment LAB=' + ex.Lab_Country__c);
    return null;}

}
Hello Everyone,
I need to create a formula field off of the Created by Date.  I'm looking to create a field that will calculate the following:
2 weeks after created date
30 days after created date
60 days after created date
90 days after created date

I have looked over documents but still hard to understand.  if you could EXPLAIN to me how i create and the syntax format that would be greatly appreciated. 
 
I have below Usecase

I have a Master detail relation.
I have Two pages displaying list of objects.

Page1 - Displaying list of Oject1 and Object 2

pageblocktable (Displaying List of Object A and List of Object B, Columns in Object B are dependent on values of Object A)
Column1A | Column2B | Column2C | Column2D 

Page2 - Displaying list of Oject2 (No problem is this one)

Object1 (Detail)
-Column1A Text
-Column1B Picklist(Controlling)
-Column1C Picklist(Dependend on Column1B)
-Column1D LookupUser

Object2 (Master)
-Column2A //Want it same as Column2A
-Column2B Picklist(Controlling)  //Want it same as Column2B 
-Column2C Picklist(Dependend on Column2B)
-Column2D                        

Is it feasible to do ?
If so what are logical steps ?
  • February 26, 2015
  • Like
  • 0

I am diplaying the value of multiselct picklist as checkboxes and it shows up correctly. The only thing which I am not able to achieve is, I want to display the checkboxes in three columns, like if I have 12 values for multiselect picklist then the checkboxes should show up in 4 coulmns and 3 rows. And in future if I add more values to the multi-select picklist the next checkbox should automatically be shown in the next column.

At present the checkboxes they all show up in 12 rows (for 12 values) and in one column.

The Visualforce code for getting the multi-select picklist value as checkbox is below:

<apex:selectCheckboxes value="{!slctCheckboxes}" id="selctCB" layout="pageDirection" >
<apex:selectOptions value="{!MultiPickNums}" id="selctOPT"></apex:selectOptions>

I don't know what CSS,HTML or JavaScript to apply to achieve it. Please HELP!!

Hello,

I have write trigger on Contact before insert and before update for avoiding duplicate entry of Email.

Here is my code
trigger DuplicateEmail on Contact (before insert, before update)
{
	Contact val_con = trigger.new[0];
    Contact prev_contact_rec = null;
    if(val_con.Email != null && val_con.Email != '')
    {
        try
        {
            if (trigger.isInsert)
            {
                prev_contact_rec = [select Email from Contact where Email=:val_con.Email limit 1];
                system.debug('----->>> Email Before Insert New: ' + val_con.Email);
            }
            else if (trigger.isUpdate)
            {
                prev_contact_rec = [select Email from Contact where Email=:val_con.Email and Id !=:val_con.Id limit 1];
                system.debug('----->>> Email Before Update New: ' + val_con.Email);
                system.debug('----->>> Id Before Update New: ' + val_con.Id);
            }
            
            if(prev_contact_rec.Email != null && prev_contact_rec.Email != '')
            {
                Trigger.new[0].adderror('Email you provided has already exists');
            }
        }
        catch (exception ex)
        {
            System.debug('Error occurd: ' + ex);
        }
        
    }
}

It is working fine when inserting new contact. But when i update the email address of existing contact then the trigger gets old value of email field instead of new value for example old value of email was "foo@yahoo.com" i have updated it to "foo123@yahoo.com" instead of assigning "foo123@yahoo.com" value to val_con object it assigns "foo@yahoo.com" to it in case of before update trigger event.
Can some body help me how to fix it.

Thanks,
Shahab