• sdb
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 10
    Questions
  • 10
    Replies

Recently <packageVersions> have begun appearing in the metadata files for some of my apex classes. If I am understanding the doc correctly, this would happen if an apex class makes a call to code in a managed package. But as far as I can tell, no such calls exist. Any idea what would cause this to happen? 

  • May 15, 2013
  • Like
  • 0

When a user registers for our site they get a new user email generated by Salesforce. However, the email contains only the user's username, not the password.

 

Here is how the new user is created:

 

Site.createPortalUser(user, accountId, password, true);

 

Is there anyway to get the password into the email sent to the new user?

 

 

  • October 16, 2012
  • Like
  • 0

When registering a portal user we are creating the contact, the Non-Profit Starter Pack automatically creates the individual account for the contact, then we set the individual account owner id to a user (always the same one) who is in the role hierarchy. Then we call Site.createPortalUser. This was all working fine, but a few days ago we started seeing the following error more and more often:

 

There was an error in registering a user in site Application_Portal. The error message is: portal account owner must have a role

 

There could be over a 1000 portal users whose accounts are all owned by this same portal owner user. Could this be the cause of the problem? Is there a limit on how many individual accounts a portal owner user can own?

  • August 10, 2012
  • Like
  • 0

I have a custom component that wraps some contact fields. What I am finding is that if I manually place the component on my VF page (scenario 1), then when the user clicks submit and a validation error occurs all the data that I typed in is retained when the validation error is shown.

 

However, if I add this component to the page dynamically using the <apex:dynamicComponent> tag (scenario 2),  then when the user clicks submit and a validation error occurs all the data that I previously typed in is lost when the validation error is shown.

 

Example Scenario 1: User enters a value of 'John' for firstName but does not enter a value for lastName. Submit is clicked, required field error is shown, the value of 'John' still appears in the firstName field.

 

Example Scenario 2: User enters a value of 'John' for firstName but does not enter a value for lastName. Submit is clicked, required field error is shown, all fields in the component including firstName have lost their values.

 

Is this to be expected with dynamically added components? Any ideas on what I might be doing wrong here?

 

TIA for any help 

  • July 12, 2012
  • Like
  • 0

Is it possible to convert a Date field to a Datetime value in a formula field? 

  • June 30, 2012
  • Like
  • 0

I know that this contradicts the SF documentation which states that a User's username must be unique across all organizations, however I am finding that this is not true when the user is created using Site.createPortalUser from a Site self-registration page.  For example, I have an SF developer account that I created last year using my personal email address. When I login to SF and look at the username for my User record it is my personal email address.  If I try to create a new developer account at login.salesforce.com using that same email address I am prevented from doing so. So far so good.

 

However, I also have a Site associated with a different SF organization, and this Site allows user's to self-register using their email address. The email address is currently being used as the Username when the User is created. When self-registering from this Site, I am able to register using the same personal email address that was already used when I set up my developer SF account. I am however prevented from duplicating that Username within that organization.

 

I have screenshots showing the same Username being used in two different SF accounts, so believe me this is happening. I am speculating that the reason that this works is because when you come in via the login.salesforce.com url, the organization wide uniqueness of the Username must be enforced because the Username is used to identify and route the user to the org that the he belongs to. However when you come in via the Site url, the organization is already known, so cross-organization uniqueness is not checked when the user is created.

 

Can anyone from Salesforce comment on this? Have I found a loophole that will be closed, or is this the way that things work?

 

 

  • June 25, 2012
  • Like
  • 0

From a functionality standpoint these Site generated pages are working just fine for me. But I was wondering if there is a way to control the validation error message that is shown to the user when they hit 'Submit' without entering a value for a required field. For example, on SiteLogin if the user hits submit without entering a value for Username they see this message:

 

loginPage:SiteTemplate:siteLogin:loginComponent:loginForm:username: Validation Error: Value is required.

 

What I'd prefer to display is:

 

Username: Value is required.

 

Is there any way for me to change the message that is generated for validation errors on SiteLogin and SiteRegister?

 

Thanks!

  • January 26, 2012
  • Like
  • 0

I have a fieldset that encapsulates fields from Contact: salutation, firstName, middleName and lastName. The fieldset looks like this within my Visualforce page:

 

<apex:repeat value="{!$ObjectType.Contact.FieldSets.Personal_Information}" var="pi" >             

      <apex:inputField id="personalInfoContact" value="{!contact[pi]}" />         

</apex:repeat>

 

I'd like to be able to reference the lastName field within the fieldset from JavaScript. Is there any way to get the id of a field within a fieldset?

  • November 06, 2011
  • Like
  • 0

I've seen in the doc that it is possible to add an error to a specific sObject field using dot notation. Ie 

 

Account myAccount  = [select an account];

myAccount.phone.addError("Invalid phone number");

 

It also appears to be possible to get a field's value by passing the field name as a string. 

 

In both cases you need to know the specific sObject and field name ahead of time. What I would like to do is write a generic method that iterates over the list of fields associated with any sObject, checking to see if a field is in error.

 

In pseudo code this would look something like this:

 

public Boolean recordHasFieldsInError(sObject s) {

Boolean inError = false;

List<Field> fields = sObject.getFields();

for(Field f: fields) {

if(f.hasError()) {

inError = true;

break;

}

}

return inError;

}

 

Is there a way to do this in Apex without knowing the sObject type or the names of the fields ahead of time?

  • October 17, 2011
  • Like
  • 0

What I'm trying to do is dynamically enable and disable an apex commandButton depending on whether a checkbox is checked or unchecked. The commandButton is starting in a disabled state, and if I check the checkbox I want to enable the commandButton. What happens is that the commandButton does in fact become enabled (if I click it, the form is submitted), but visually the commandButton still appears to be disabled. However if I do the same thing with a regular input button, everything works fine -- ie the input button appears enabled when enabled and disabled when disabled.  Below is a very simple VF page that demonstrates the problem.

 

<apex:page sidebar="false"> 

<apex:form >   

<apex:pageBlock >     

<apex:pageBlockButtons id="buttonBlock" location="top">       

<apex:commandButton id="myCmdButton" value="Disabled Apex Command Button" disabled="true"/>       

<input id="myButton" type="button" value="Disabled Input Button" disabled="true"></input>       

<input id="myCheckbox" type="checkbox" onclick="cbxOnClick()">Enable Buttons</input>       

<script>           

var cmdBtn = document.getElementById('{!$Component.myCmdButton}');           

var btn = document.getElementById('myButton');           

var cbx = document.getElementById('myCheckbox');                                     

function cbxOnClick() {           

btn.disabled=!cbx.checked;               

btn.value=(cbx.checked? "Enabled Input Button":"Disabled Input Button");               

cmdBtn.disabled=!cbx.checked;               

cmdBtn.value=(cbx.checked? "Enabled Apex Command Button":"Disabled Apex Command Button");           

}                                                                                                 

</script>     

</apex:pageBlockButtons>   

</apex:pageBlock>         

</apex:form>       

</apex:page>

  • October 15, 2011
  • Like
  • 0

I have recently started using the new Developer Console quite a bit. It's a great tool, but I am experiencing an error that I have never seen before when using it: 

 

Organization Administration Locked

The changes you requested require salesforce.com to temporarily lock your organization's administration setup. However, the administration setup has already been locked by another change. Please wait for the previous action to finish, then try again later. 

 

When this happens a lock is placed on an Apex class and I cannot edit it.  Any idea how to get out of this locked state? I have tried logging out of Salesforce and logging back in again multiple times.

  • October 31, 2012
  • Like
  • 0

I have a custom component that wraps some contact fields. What I am finding is that if I manually place the component on my VF page (scenario 1), then when the user clicks submit and a validation error occurs all the data that I typed in is retained when the validation error is shown.

 

However, if I add this component to the page dynamically using the <apex:dynamicComponent> tag (scenario 2),  then when the user clicks submit and a validation error occurs all the data that I previously typed in is lost when the validation error is shown.

 

Example Scenario 1: User enters a value of 'John' for firstName but does not enter a value for lastName. Submit is clicked, required field error is shown, the value of 'John' still appears in the firstName field.

 

Example Scenario 2: User enters a value of 'John' for firstName but does not enter a value for lastName. Submit is clicked, required field error is shown, all fields in the component including firstName have lost their values.

 

Is this to be expected with dynamically added components? Any ideas on what I might be doing wrong here?

 

TIA for any help 

  • July 12, 2012
  • Like
  • 0

Is it possible to convert a Date field to a Datetime value in a formula field? 

  • June 30, 2012
  • Like
  • 0

I know that this contradicts the SF documentation which states that a User's username must be unique across all organizations, however I am finding that this is not true when the user is created using Site.createPortalUser from a Site self-registration page.  For example, I have an SF developer account that I created last year using my personal email address. When I login to SF and look at the username for my User record it is my personal email address.  If I try to create a new developer account at login.salesforce.com using that same email address I am prevented from doing so. So far so good.

 

However, I also have a Site associated with a different SF organization, and this Site allows user's to self-register using their email address. The email address is currently being used as the Username when the User is created. When self-registering from this Site, I am able to register using the same personal email address that was already used when I set up my developer SF account. I am however prevented from duplicating that Username within that organization.

 

I have screenshots showing the same Username being used in two different SF accounts, so believe me this is happening. I am speculating that the reason that this works is because when you come in via the login.salesforce.com url, the organization wide uniqueness of the Username must be enforced because the Username is used to identify and route the user to the org that the he belongs to. However when you come in via the Site url, the organization is already known, so cross-organization uniqueness is not checked when the user is created.

 

Can anyone from Salesforce comment on this? Have I found a loophole that will be closed, or is this the way that things work?

 

 

  • June 25, 2012
  • Like
  • 0

Hey folks, I'm in a new role now, so I will be coding a lot more.  Looking forward to hanging out in here more often!

 

I'm working with Dynamic Visualforce at the moment (apex:dynamicComponent) to build a simple Lead form.  It's a long story why it has to be built dyamically.  I'm extending the standard Lead controller, and leveraging the standard {!save} method.  It works great when the record saves... they are brought to the new record and all the info they entered is there... woohoo!

 

The problem is when they click save but haven't filled in one or more required fields.  The form refreshes and correctly identifies the fields they forgot to populate and notifies them as is appropriate.  BUT, all the info they had entered is cleared out!

 

Here is a small example that shows what I mean:

 

Visualforce Page:

<apex:page extensions="dynamicTestController" standardController="Lead">

    <apex:messages />

    <apex:form >
        <apex:pageBlock mode="edit">

            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!save}"/>
            </apex:pageBlockButtons>
            
            <apex:dynamicComponent componentValue="{!mySection}"/>
            
        </apex:pageBlock>
    </apex:form>
</apex:page>

 

 

Apex Controller:

public with sharing class dynamicTestController {

    public Lead theLead {get;set;}

    public dynamicTestController(ApexPages.StandardController controller) {
        theLead = (lead)controller.getRecord();
    }

    public Component.Apex.PageBlockSection getMySection() {
        
        Component.Apex.PageBlockSection section = new Component.Apex.PageBlockSection(columns=1);
        
        Component.Apex.InputField field1 = new Component.Apex.InputField();
        field1.expressions.value = '{!theLead.LastName}';
        
        Component.Apex.InputField field2 = new Component.Apex.InputField();
        field2.expressions.value = '{!theLead.Company}';
        
        Component.Apex.InputField field3 = new Component.Apex.InputField();
        field3.expressions.value = '{!theLead.Phone}';
        
        section.childComponents.add(field1);
        section.childComponents.add(field2);
        section.childComponents.add(field3);
        
        return section;
    }
}

 

 

 

You can see that when you populate LastName and Phone, but NOT Company and click save the form is cleared out... not cool!

 

I've concocted a workaround, which is to use a custom save method that returns nothing so I can avoid refreshing of the form.  I then use the apex:messages component to display any errors at the top of the page and redirect with JavaScript if there are no errors.  It works, but then errors that should be on a specific field are at the top instead and I would rather not have to rely on JS for navigation like that.

 

Any thoughts?

 

Cheers,

michaelforce

I have a fieldset that encapsulates fields from Contact: salutation, firstName, middleName and lastName. The fieldset looks like this within my Visualforce page:

 

<apex:repeat value="{!$ObjectType.Contact.FieldSets.Personal_Information}" var="pi" >             

      <apex:inputField id="personalInfoContact" value="{!contact[pi]}" />         

</apex:repeat>

 

I'd like to be able to reference the lastName field within the fieldset from JavaScript. Is there any way to get the id of a field within a fieldset?

  • November 06, 2011
  • Like
  • 0

What I'm trying to do is dynamically enable and disable an apex commandButton depending on whether a checkbox is checked or unchecked. The commandButton is starting in a disabled state, and if I check the checkbox I want to enable the commandButton. What happens is that the commandButton does in fact become enabled (if I click it, the form is submitted), but visually the commandButton still appears to be disabled. However if I do the same thing with a regular input button, everything works fine -- ie the input button appears enabled when enabled and disabled when disabled.  Below is a very simple VF page that demonstrates the problem.

 

<apex:page sidebar="false"> 

<apex:form >   

<apex:pageBlock >     

<apex:pageBlockButtons id="buttonBlock" location="top">       

<apex:commandButton id="myCmdButton" value="Disabled Apex Command Button" disabled="true"/>       

<input id="myButton" type="button" value="Disabled Input Button" disabled="true"></input>       

<input id="myCheckbox" type="checkbox" onclick="cbxOnClick()">Enable Buttons</input>       

<script>           

var cmdBtn = document.getElementById('{!$Component.myCmdButton}');           

var btn = document.getElementById('myButton');           

var cbx = document.getElementById('myCheckbox');                                     

function cbxOnClick() {           

btn.disabled=!cbx.checked;               

btn.value=(cbx.checked? "Enabled Input Button":"Disabled Input Button");               

cmdBtn.disabled=!cbx.checked;               

cmdBtn.value=(cbx.checked? "Enabled Apex Command Button":"Disabled Apex Command Button");           

}                                                                                                 

</script>     

</apex:pageBlockButtons>   

</apex:pageBlock>         

</apex:form>       

</apex:page>

  • October 15, 2011
  • Like
  • 0

Hi All,

 

I am trying to get visitors of a site to self-register as members using the customer portal. This is something I have done a few times now, but in this case is not working.

 

The logic I during self registration is as follows:

 

- create a user, user

- create an account of type person account

- insert the account

- change the account owner to a system admin with a role assigned

- update the account

- get the accountId

- make the following call --> ID userId = Site.createPortalUser(u, accountId, password);

 

The above call return userId=null, so that the customer portal user is not created.

 

I have tried to do "manually"what  the Site.createPortalUser call does internally and it works. What I have done is as follows:

 

- create a user, user

- create an account of type person account

- insert the account

- change the account owner to a system admin with a role assigned

- update the account

- get the accountId

- get the PersonContactId (since this is a Person Account)

- assiign  user.ContactId = PersonContactId

- assing user.profileId = (Id of the customer portal user profile)

- insert user

 

This gets me a valid userId and the person account is created and enabled for the customer portal okay.

 

On that basis I have tried again the call to  Site.createPortalUser but instead of the accountId tried passing the PersonContactId (since it is a person account) and this did not work.

 

Any ideas would be very much appreciated.

 

Thanks in advance