• Andrew2X
  • NEWBIE
  • 0 Points
  • Member since 2009

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 9
    Replies
One of our customers is experiencing an issue where a query to the standard UserRole object is returning no results for some users and correct results for others.

At first I thought this was a permissions issue, but I could find no place in Salesforce where one can set permissions on the UserRole object. Also, one of the users this issue happens to has 'System Administrator' profile (i.e. 'Modify All')

The code is as follows... in Apex, there is a SOQL query to get a list of all roles: 

for(UserRole[] roles : [SELECT Id, Name
     FROM UserRole
     WHERE (PortalType = null OR PortalType = 'None')
     ORDER BY Name
     LIMIT 1000])
{
}

This works fine all of the time for all users. The results of this query is used to populate a drop-down box to allow the user to select a particular Role.

Later, the selected Role is used in another query:

for (UserRole userRole : [SELECT Id, Name
    FROM UserRole
    WHERE Id = :roleId])
   {
   }

Here, the :roleId is the one selected previously by the user. In all cases, it's a valid UserRoleId, but the issue is that for some users this returns a valid Role and for others it returns nothing.

I have not been able to reproduce the error in our Salesforce orgs, and it happens only for one single customer and not for our other customers. I have done a lot of investigating to try to solve this issue but am completely stumped.

I tried using Developer Console to see what the exact query is being sent to Salesforce, but it has been no help because it does not reveal the exact query, but something like this: 'SELECT Id, Name FROM UserRole WHERE Id=:tempVar1

Any help would be greatly appreciated.

Thanks,
Andrew

Do Chatter Only users have permissions for custom apps? The documentation does not say so specifically. Can someone confirm for me that 'Chatter Only' users can't use custom AppExchange apps.

 

I appreciate your response

One of our customers suddenly started getting this message today. It occurs when an AJAX request is made to fetch Asset records. The user is using Safari browser, and I have tried running the application myself in Safari but did not get this error.

 

This is not a cross site AJAX request, it's a normal sfdc AJAX request to fetch some records, and it works fine in Firefox and IE.

 

Does anyone know what might cause this error?

Hi All,

 

One of our customers is getting this error message when a lenghty process is being run. Several batches of accounts are fetched from SFDC and processed. The error occurs after about 400 batches are fetched. The first 400 batches fetch and process without errors, then suddenly in the request for the next batch the error occurs.

 

I've examined v16.0 of connection.js and found a line of code that is setting the SOAPAction header on each AJAX request, which is not surprising since the requests work most of the time. The problem seems to be that the header isn't being set on the request after about 400 requests.

 

Here is the JavaScript code that is being executed:

 

 

    this.fetchFirstBatch = function()
    {
        this.sObjects = [];
        var queryString;

try
{
sforce.connection.batchSize = 200;
sforce.connection.batchSizeSpecified = true;

queryString = "SELECT Id, " +
this.fieldNames.streetField + ", " +
this.fieldNames.cityField + ", " +
this.fieldNames.stateField + ", " +
this.fieldNames.postalCodeField + ", " +
this.fieldNames.countryField +
" FROM " + this.objectName + " WHERE " +
this.fieldNames.statusField + " = null " +
(this.objectName == "Lead" ? "AND IsConverted = false " : "");

this.queryResult = sforce.connection.query(queryString);
this.sObjects = this.queryResult.getArray('records');

this.firstBatchFetched = true;
}
catch(error)
{
alert("Fetch " + this.objectName + " failed with error: " + error);
}
};


    this.fetchNextBatch = function()
    {
        this.sObjects.length = 0;    
    
        try
        {
            this.queryResult = sforce.connection.queryMore(this.queryResult.queryLocator);
            this.sObjects = this.queryResult.getArray('records');
        }
        catch(error)
        {
            alert("Fetch next " + this.objectName + " batch failed with error: " + error);
        }
    };

 

 

This code results in an alert with:

 

Fetch next Account batch failed with error: {faultcode:'soapenv:Client', faultstring:'SOAPAction HTTP Header missing', }

 

How can I set the SOAPAction header explicitly before each call to query or queryMore? I've tried sforce.connection.setRequestHeader but get an error saying that method doesn't exist.

 

The error is occuring in the latest versions of Firefox, IE and Chrome. It's possible that this error started happening only recently because other customers have run this processing with huge number of accounts in the past without any errors.

Hi All,

 

When the DateTime format method is used like this:

 

dateTimeValue.format('MMM-dd-yyyy - hh:mm a');

 

it returns a string like this: May-29-2010. The month name is in English. I've switched my Salesforce org to French, but the output is identical. I'd like to see something like this: Mai-29-2010 where the month is localized to French (Mai). Otherwise, French speaking users will see English month names and might get confused.

 

Is there anyway to localize the output of the DateTime.format method?

 

Thanks for your help.


I've struggled with this for a while, and searched the discussion boards and found nothing similar, so I've come to the conclusion that this must be a bug.

I have a commandButton that's part of a pageBlockButtons section:

<apex:commandButton action="{!saveAccountView}" value="Save View" rendered="{!AND(selectedViewId=null,NOT(selectedAccountId=null))}" />

That's the tag exactly as it appears on the page. The action method should navigate to a different page. Everything works fine if I remove the rendered attribute.  With the rendered attribute, the action method is never invoked, the page just refreshes. What's weird is that I have another commandButton on the page with pretty much the same rendered attribute and it works fine. I've tried changing the rendered attribute to:

 

<apex:commandButton action="{!saveAccountView}" value="Save View" rendered="{!showButon}" />

but that doens't work.


I've worked around this by using the style="visiblity:{!condition}", but I don't like this solution.


 

Is this possible? I want to add a Custom Button to the List View for Accounts, Opportunities, Leads, etc. When the button is clicked a VF page is navigated to, and some processing occurs, and this processing doesn't care what object is being listed--it just saves a list of the object Ids that the user has selected (checked) from the list.

 

As it is, I have to create a separate VF page for each Object and put

 

 

<apex:page standardController="Account" extensions="MyListController" action="{!init}" recordSetVar="items"

 

Then I have to do another page for Opportunites where the only difference is standardController='Opportunities'

 

Also, this makes it impossible to use the Custom Button on List View's of Custom Objects since a new VF page would have to be created for each Custom Object that supports the Button on their lists.

 

 

 

 

One of our customers suddenly started getting this message today. It occurs when an AJAX request is made to fetch Asset records. The user is using Safari browser, and I have tried running the application myself in Safari but did not get this error.

 

This is not a cross site AJAX request, it's a normal sfdc AJAX request to fetch some records, and it works fine in Firefox and IE.

 

Does anyone know what might cause this error?

Here is the situation. I have a trigger on an opportunity that calls an asynchronous @future method which runs some logic and updates the opportunity. I also have several roll-up summary fields on the opportunity. When I run on updated on on OpportunityLineItem this executes the Opportunity trigger and queues up the @future method  which is throwing this error a lot: UNABLE_TO_LOCK_ROW, unable to obtain exclusive access to this record.


According to the documentation here, http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_concepts_core_data_objects.htm , it says transactions that included a summary field (I assume it means roll up summary field) are especially prone to deadlocks. This makes me think that roll-up summary fields are also an asynchronous action but I am still looking for confirmation. If you know please respond.

 

UPDATE: Documentation here, http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_triggers_order_of_execution.htm , makes it sound like roll-up summary fields are a synchronous operation. I'm confused. I think roll-up summary calculation may be synchronous if you edit the parent and asynchronous if you edit a child?

 

This is my theory. Trigger on opp fires and queues up both the @future method and the roll-up summary recalculation. Both are asynchronous (assumption) and they are both trying to update the opp at the same time. So how to solve this problem? Below is one possible idea but I have no idea if it would even work.

 

 

try{
	update oppsToUpdate;
}catch(Exception e1){
	if(e1.getMessage().contains('UNABLE_TO_LOCK_ROW')){
		try{
			update oppsToUpdate;
		}catch(Exception e2){
			if(e2.getMessage().contains('UNABLE_TO_LOCK_ROW')){
				try{
					update oppsToUpdate;
				}catch(Exception e3){
					//error handing after 3 failed updated attempts
				}
			}
		}
	}else{
		//other error handling
	}
}

 

This would attempt to updated the opp 3 separate times if the error returned is unable to lock row. Some unknowns here that hopefully someone with direct saleforce.com knowledge can address is are these three updated statements truly unique and separate update transactions or will the record being updated appear locked for the entire duration of the class execution? The updates would also me milliseconds apart and I don't know if the delay would be enough for the record to unlock.

 

If anyone has suggestions for this tricky problem I am all ears.

 

Thanks,

Jason

  • September 14, 2010
  • Like
  • 0

Hi All,

 

When the DateTime format method is used like this:

 

dateTimeValue.format('MMM-dd-yyyy - hh:mm a');

 

it returns a string like this: May-29-2010. The month name is in English. I've switched my Salesforce org to French, but the output is identical. I'd like to see something like this: Mai-29-2010 where the month is localized to French (Mai). Otherwise, French speaking users will see English month names and might get confused.

 

Is there anyway to localize the output of the DateTime.format method?

 

Thanks for your help.


I've struggled with this for a while, and searched the discussion boards and found nothing similar, so I've come to the conclusion that this must be a bug.

I have a commandButton that's part of a pageBlockButtons section:

<apex:commandButton action="{!saveAccountView}" value="Save View" rendered="{!AND(selectedViewId=null,NOT(selectedAccountId=null))}" />

That's the tag exactly as it appears on the page. The action method should navigate to a different page. Everything works fine if I remove the rendered attribute.  With the rendered attribute, the action method is never invoked, the page just refreshes. What's weird is that I have another commandButton on the page with pretty much the same rendered attribute and it works fine. I've tried changing the rendered attribute to:

 

<apex:commandButton action="{!saveAccountView}" value="Save View" rendered="{!showButon}" />

but that doens't work.


I've worked around this by using the style="visiblity:{!condition}", but I don't like this solution.


 

Hi, I am trying to make an attachment page on one of my custom pages. I am unable to find any totorial for this particular purpose. Can somebody please refer me to some tutorial that associates an attachment to the custom objects and controls.

 

I came accross teh follwoing example of uploading attachments. I am unable to run this code because I dont find any option to create the extension for the standardController-Document

 

    

<apex:page standardController="Document" extensions="documentExt"> <-- Upload a file and put it in your personal documents folder--> <apex:messages /> <apex:form id="theForm"> <apex:pageBlock> <apex:pageBlockSection> <apex:inputFile value="{!document.body}" filename="{!document.name}"/> <apex:commandButton value="save" action="{!save}"/> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page> /*** Controller ***/ public class documentExt { Appendix D: Standard Component Reference inputFile public documentExt(ApexPages.StandardController controller) { Document d = (Document) controller.getRecord(); d.folderid = UserInfo.getUserId(); //this puts it in My Personal Documents } }

 

Can someone please help me in:

1- How can I associate an attachments to my records when I am working with a custom controller (some code or step by step tutorial).

2- How can I add an extension when I am using a standard controlle

Hi All,

 

I would like to be able to call the SF Metadata API from Apex code in my custom app.

 

I went to Setup/App Setup/Develop/API and clicked on 'Download Metadata WSDL' and saved it to my hard drive.

 

Then I went to Setup/App Setup/Develop/ApexClasses and clicked on the 'Generate from WSDL' button. For Step 1, I navigate to the Metadata WSDL that I just saved and click 'Parse WSDL.' This takes me to the Step 2 screen where I then click on the 'Generate Apex code' button.

 

This takes me to the Step 3 screen which shows this error:

 

<error>

Apex generation failed.

Error message:
Error: Class name 'Metadata' already in use. Please edit WSDL to remove repeated names

 

</error>

 

Does this error mean that what I am attempting to do is not allowed? If it is allowed, how do I get around this error.

 

Any help would be appreciated.

 

Thanks,

Andrew