• jonathanrico.
  • NEWBIE
  • 55 Points
  • Member since 2008


  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 31
    Questions
  • 78
    Replies

Hi everyone,

 

I'm trying to load a file and associate it to an object's chatter feed through VisualForce. I've done this before in another org but i'm having some issues now. Has anyone got this error message before:

 

First Publish Location: Content cannot be inserted as a child of record a0UK0000000UVe1 (this is Id of the Custom Object record I'm trying to associate the file to).

 

Here's how i'm creating the file:

 

//Create custom object record
Document__c doc = new Document__c();
doc.Name= 'File wrapper';
doc.Description__c='Sample description';
insert doc; 

//Create ContentVersion and associate to custom object record
ContentVersion myContent = new ContentVersion();
myContent.VersionData = fileBody;
myContent.Description = doc.Description__c; 
myContent.PathOnClient = fileName;
myContent.Origin = 'H';
myContent.FirstPublishLocationId = doc.id;

insert myContent;

 

Any ideas on why isn't this working anymore? 

 

If I don't specify a FirstPublishLocationId everything works fine, also I made sure that Chatter is enabled for my custom object and Content is enabled for the org.

Hi,

 

It looks like there's a bug when using custom connections with the Windows Chatter desktop client.  Users downloaded the lastes version of Chatter desktop and when entering a custom domain the "Add" button remains disabled, however, if we try "login.salesforce.com" or "test.salesforce.com" the Add button becomes enabled.

 

We tried entering the domain with and without "https://" but got the same results. Any ideas? Is this a known issue?

Hi everyone!

 

I want to extend the capabilities of a ContentDocument with a Custom Object, VF & Apex.

 

Are there any limitations I should be aware of when trying to load ContentDocuments through Apex, is it possible to programatically create, update, upload, etc.. this kind of objects?

 

My main concern is file size...

 

I would appreciate any advice related to this, thanks in advance!

Hello Everyone,

 

Does anyone know if its possible to bring the translated value of a Picklist field in a Text Formula Field.

 

I currently have a status picklist field in Object A. Object B is a detail of Object A and I need to display the value of the status field in Object B.

 

I need to support multiple languages, however, when using translations the picklist label translates perfectly at the Object A level but the child records of Object B display the original value.

 

I guess formula fields always retrieve the master labels, is there anyway to get around this in order to get the translated value?

 

Thanks in advance!

Hello everyone

 

I'm currently working with generating sharing rules dynamically using Apex.

 

I noticed that if I insert a sharing rule that has been defined previously there is no duplicate sharing rule inserted. Im guessing there's some logic that determines that an identical sharing rule has been defined and therefore it is not inserted. Am I right?

 

If this is the case, should I still verify that no duplicate sharing rules will be inserted o just rely on Force.com to avoid duplicate sharing rules for me?

 

Thanks in advance!

 

 

Hello everyone

 

I'm trying to hide the setup section for a specific profile but this doesn't seem possible. I don't want certain users (Salesforce Platform license) to be able to reset their security token or even see their user details. Is there a way to do this?

 

I also noticed that in Customer Portal the links to users (Created By, Owner etc..) don't display as links, they appear as text. Is there a way to do this for Platform license (Force.com) users?

 

Thanks in advance! 

Hi everyone,

 

I started to get the following error message today, everything was working fine and now I can't deploy my classes because the test units fail due to some incorrect signature in the setCurrentPageReference method inside the Test class.

 

I'm getting the following error message:

 

Save error: Method does not exist or incorrect signature: Test.setCurrentPageReference(System.PageReference)

 

Any ideas on what's happening? Can this be related to the Spring '10 upgrade? It's frustrating that this kind of things happen when you're ready to deploy your stuff to production.. 

 

 

 

 

 

 

Hello everyone, I've recieved nothing but great feedback from the autocomplete component I posted previously here in the discussion boards. So here's something else I would like to share with you.

 

Apex Object Merge Class

 

This apex class allows merge operations on a any custom object, please feel free to read more about it here:

 

http://jonathanrm.com/2010/02/force-com-apex-mergereplace-class/

Message Edited by jonathan rico on 02-07-2010 01:54 PM

Hello everyone, I'm trying to override the "Go to list (x)+" link that displays in related list so that It points to a VisualForce page.

 

Overriding the List View for the object in the setup section took care of this, but in order to override the List View I must use a page that is linked to a StandardSetController (using recordSetVar) in order to have it as an available option for override.

 

Everything went fine untill that point.. but 

 

When displaying the records from the  standardset controller I get the list of All of the records and not only the ones from the related list i'm coming from.

 

I supposed this was because there was no way for my VF page to know which are the selected records, or something similar.. so I decided that then I should build my custom related list, but then I noticed that my VF page only recieves a rlid parameter with what I suppose is the id of the child relationship from the parent object.

 

However I don't have the parent Id anymore in the new page and I need this to create my custom set controller in order to get the correct set of records.

What's weird is that if I hover the "Go to list (x)" link I see that the url contains the same rlid parameter and the parent Id, but I'm not sure why the parent Id is removed when overriding the link with visualforce.

 

What would be ideal is that overriding a list view takes care of all of this, and that it knows that it should only display records from the parent object from which i'm coming from. Maybe this is possible and I'm doing something wrong, if this is the case let me know and I'll post my code. 

 

If this is working as designed, then I should build my custom related list but I need to find a way of getting the parent's id in order to limit the set of records.

 

Please let me know if anyone else has bumped into this. If this is working as designed, then what is the real purpose of overriding a List for an Object?

 

Thanks in advance!

Message Edited by jonathan rico on 02-03-2010 02:40 PM

Hello everyone,

 

I've been having an issue in the last weeks, it all started in sandbox and now I'm seeing the same behavior in production and that's why I need your help.

 

When using my VF pages in Customer Portal, the colors of sections and fonts (defined in the Customer Portal customization section) change completely when doing an AJAX call, this is very strange since it was working without any problems. I noticed this only happens in Customer Portal, any ideas?

 

Thanks in advance!

 

Message Edited by jonathan rico on 12-28-2009 08:12 PM

Hello everyone,

 

We are having some issues when inserting a list of objects through WebServices API. It seems that a list of records is not inserted in the same order as they come in the list. We looked at the SFDC IDs and some of the records that are not at the beginning of the list are inserted with the first SFDC IDs and then the sequence of IDs stops and then it starts somewhere else.

 

Has anyone else had this kind of issue? Order of IDs is important for what we are trying to build,when we insert a list records through Apex we don't see this behavior with the IDs, however when doing the same thing with webservices we don't see the same results.

 

Thanks in advance! 

Hello everyone

 

I'm having an issue using Force.com sites and Standard Set Controllers pagination. The problem is the following:

 

If an anonymus user is in the site they can change pages within a Standard Set Controller without any problems, but if I then login to the site as a Customer Portal user I start having some issues.

 

Once logged in I'm redirected to the same page, the records of the first page of the Standard Set show up but when I try to go to another page of the Standard Set Controller I get a "Site under maintenance" page.

 

I then logged in as a Customer Portal without using the Sites login component. Onced logged in, my URL is different, it's not the one configued for Force.com sites because I didn't came from Force.com sites. If I go to the page that references the Standard Set Controller (http://naX.../apex/MyPage)I can navigate through the pages of the Standard Set Controller without any problems.

 

Any idea of how to handle this issue?

 

Thanks in advance!

Hello everyone

 

Quick question, is it possible to enable WebServices API for Customer Portal Users? I can't find a way to create a security token to make the login call. I guess that I should also send other paramaters such as the portal..

 

Thanks in advance for your help!

 

Hello everyone,

 

I'm currently getting this error when opening a VF page that makes use of webservice callouts.. however... I don't what's the problem.. I think this is not a Max Callout Size issue, otherwise I'll get " Exceeded max size limit of 100000 with response size XXXX" and i'm just getting "Exceeded max size limit of 100000". Any idea of what this means?

 

Hello everyone, I'm trying to display a list of results from a Standard Set Controller, but it seems that the entries are not being sorted, any ideas on why it's not working?

 

Here's a piece of my code:

 

 

List<Blog_Post__c> blogposts = new List<Blog_Post__c>();
blogposts = [select id,
name,
CreatedBy.name,
CreatedDate,
Content__c,
Content_Type__c,
Align_Content__c

from Blog_Post__c order by createddate desc];

controller = new ApexPages.StandardSetController(blogposts);

 

Thanks in advance!

 

 

Message Edited by jonathan rico on 07-01-2009 08:47 PM

Hello everyone,

 

I'm currently working with customer portal, don't know if this also happens outside of Customer Portal, but when I have a paramter in the url that has double underscore, suchas as theparam=thevalue__x, I get an Insufficient Privileges Error.This was not happening yesterday...

 

Any idea on why this is happening?

 

Thanks in advance.

Hello,

 

Anyone else having Internal Server errors in na6 instances???

This has being going on all day.

Hello everyone, just a quick question..

Is there a way to enable the list view checkbox functionality for selecting multiple items in Customer Portal? I'm trying to create a VF page with the listviews component but I need to be able to leverage the existing functionality in order to select multiple items and then perform mass actions to these.

Thanks in advance.
Hello everyone,

I'm trying to figure out a behavior with IE 7, I made a custom links section, each time a custom link is clicked the following javascript that opens a VF page in a new window is executed:

window.open('/apex/vf_page');

It works fine, however if I click the link a couple of times, the popup window stays in a loading state, and then I'm not able to access any other salesforce page!, not even the login page I need to restart IE in order to access salesforce again.

I tested the links using Firefox 3, and Chrome and everything works fine.

Any ideas on how to solve this issue?

Thanks in advance
Hello everyone,

I've been having some problems with an inputField that has the required option set as true. I finally narrowed down the problem to this because once I remove the required option (set it to false) I no longer have the problem.

What i'm trying to do is to call a function in my controller on the onkeyup event in one of my inputFields. Once the onkeyup event happens I send the value of my input to the controller action which returns a set of records.. Everything works fine If I only have one field set as a required field. If I have more than one required fields apparently the value of my input is not being assigned to a variable in my controller.. Any ideas?

Here's a piece of my VF page:

If I remove the required="true" option from Tracking_TFN__c.Phone_Number_Formatted__c InputField, the javascript function calls the controller action and everything works as it should, otherwise It seems that my actionFunction is not performing the assignTo="{!searchInput}" properly

Code:
 <apex:outputPanel >
 
  <apex:form >

   <apex:actionFunction name="saveRecord" action="{!c_save}" rerender="errormessageslu" status="actionstatuslu">
    <apex:param name="saveid" value="" />
   </apex:actionFunction>

    <apex:actionFunction name="searchRelated" action="{!searchRelated}" rerender="clist,ResultsLabel" status="actionstatuslu2">
    <apex:param name="searchString" assignTo="{!searchInput}" value="" />
   </apex:actionFunction>
        
      <apex:pageBlock id="newform1lu" title="{!sTitle}" mode="edit">
  
   <apex:pageBlockSection columns="1">
       <apex:outputPanel id="errormessageslu" layout="block" styleClass="searchActionStart">
                <apex:actionStatus startText="Saving..." id="actionstatuslu" />
                 <apex:pageMessages />
          </apex:outputPanel>
   </apex:pageBlockSection>
                       
         <apex:pageBlockSection title="Information" columns="1">
         
           <apex:inputField value="{!Tracking_TFN__c.Name}"  id="objname" required="true" onkeyup="searchRelated(this.value);"/>
          <script>
           add_sonameinput = document.getElementById('{!$Component.objname}');
           if('{!$CurrentPage.parameters.newid}' != ''){
            add_sonameinput.value='{!$CurrentPage.parameters.newid}';
           }
           add_sonameinput.focus();
          </script>
          
          <apex:inputField value="{!Tracking_TFN__c.Phone_Number_Formatted__c}" required="true"/>
          
          <apex:inputField value="{!Tracking_TFN__c.TFN_Code__c}" />
                                  
          </apex:pageBlockSection>
                  
          <apex:pageBlockButtons location="top"> 
           <apex:commandButton action="{!avoidRefresh}" rerender="refreshpanel" onclick="add_csave()" value="Save"  />
                    <apex:commandButton action="{!c_savenew}" rerender="errormessageslu" value="Save & New" status="actionstatuslu"/>               
                   <apex:commandButton onclick="window.close();" value="Close" immediate="true" status="actionstatuslu" />
          </apex:pageBlockButtons>
                  
     </apex:pageBlock>

 
Thanks in advance!

Test coverage in my package is failing! It seems to be failing on blank lines, closing brackets, random lines in queries and comments. Causing my code coverage to be half (or less) than what it should be!

 

None of this should be scanned.

 

Anyone else getting this problem?

Hi

 

My stuck with this feature:

 

I need to Relate (Connect) a ContentVersion object (A file I retrive from an email) I create in my Apex code to a custom object I have in the database.

 

The GUI feature that allows to do that has a Related To lookup filed but I can't find how to do this in APEX.

 

I appricate an advise

 

Thanks

 

 

  • May 20, 2011
  • Like
  • 0

I have found some info out there about Mixed_DML errors, but most of them have to do with Controllers and action chaining for VF pages. 

 

I am getting one on a trigger that attempts to do the following:

 

Up until this point every employee gets a seat in our SFDC org. We also make a Contact record for every employee to record cases, training etc. Therefore, I wanted to make a trigger that created a Contact whenever a new User record is created or upates the Contact whenever the corresponding User is edited. So the following is what I started with. The logic isn't complete, but there is enough there to get started. Anyway. it's giving me the following when I try to test by creating a new user in the interface.

 

MIXED_DML_OPERATION, DML operation on setup object is not permitted after you have updated a non-setup object (or vice versa): Contact, original object: User: []

 

What I'm confused by(take warning here, I'm a completely self-taught novice and struggling) is that the docs say that mixed dml errors occur because a single method is trying to manipulate two different sObjects, and that the solution is to have the two dml statements in two different methods one of which is tagged with @future. However, I am only trying to run DML on the Contact object, so what's the deal?

 

BTW, I'm totally open to people making suggestions on how to make this code more efficient, elegant etc.

 

 

Thanks!

 

 

trigger userTrigger on User (after insert, after update) {

	List<Contact> newCons = new List<Contact>();
	List<Contact> exCons = new List<Contact>();
	
	if(trigger.isInsert) {
		for(User newU : trigger.new) {
			Contact theCon = new Contact();
			theCon.FirstName = newU.FirstName;
			theCon.LastName = newU.LastName;
			theCon.Email = newU.Email;
			theCon.Department =newU.Department__c;
			theCon.Unit__c = newU.Unit__c;
			theCon.StartDate__c = newU.DateofHire__c;
			theCon.EndDate__c = newU.TerminationDate__c;
			theCon.Title = newU.Title;
			theCon.Phone = newU.Phone;
			theCon.AccountId = '001Q000000G7LHh';
			
			newCons.Add(theCon);
			
		}		
	}
	
	insert newCons;
	
	if(trigger.isUpdate) {
		List<Contact> existingCons = [select ID, FirstName, LastName, Email, Department, Unit__c, StartDate__c, EndDate__c, Title, Phone from Contact where Id IN :trigger.newMap.keySet()];
		for(Contact existingCon : existingCons) {
			if(existingCon.FirstName != trigger.newMap.get(existingCon.Id).FirstName) {
				existingCon.FirstName = trigger.newMap.get(existingCon.Id).FirstName;
			}
			if(existingCon.LastName != trigger.newMap.get(existingCon.Id).LastName) {
				existingCon.LastName = trigger.newMap.get(existingCon.Id).LastName;
			}
			if(existingCon.Email != trigger.newMap.get(existingCon.Id).Email) {
				existingCon.Email = trigger.newMap.get(existingCon.Id).Email;
			}
			if(existingCon.Department != trigger.newMap.get(existingCon.Id).Department__c) {
				existingCon.Department = trigger.newMap.get(existingCon.Id).Department__c;
			}
			if(existingCon.Unit__c != trigger.newMap.get(existingCon.Id).Unit__c) {
				existingCon.Unit__c = trigger.newMap.get(existingCon.Id).Unit__c;
			}
			if(existingCon.StartDate__c != trigger.newMap.get(existingCon.Id).DateofHire__c) {
				existingCon.StartDate__c = trigger.newMap.get(existingCon.Id).DateofHire__c;
			}
			if(existingCon.EndDate__c != trigger.newMap.get(existingCon.Id).TerminationDate__c) {
				existingCon.EndDate__c = trigger.newMap.get(existingCon.Id).TerminationDate__c;
			}
			if(existingCon.Title != trigger.newMap.get(existingCon.Id).Title) {
				existingCon.Title = trigger.newMap.get(existingCon.Id).Title;				
			}
			if(existingCon.phone != trigger.newMap.get(existingCon.Id).phone) {
				existingCon.phone = trigger.newMap.get(existingCon.Id).phone;
			}
			
			//newCons.add(existingCon);
		}
	}
	
	update exCons;
}

 

 

Hello Everyone,

 

Does anyone know if its possible to bring the translated value of a Picklist field in a Text Formula Field.

 

I currently have a status picklist field in Object A. Object B is a detail of Object A and I need to display the value of the status field in Object B.

 

I need to support multiple languages, however, when using translations the picklist label translates perfectly at the Object A level but the child records of Object B display the original value.

 

I guess formula fields always retrieve the master labels, is there anyway to get around this in order to get the translated value?

 

Thanks in advance!

I am trying to figure out how to test fields (included within a apex:repeat) to see if they are blank, or null, and if so display some alternate text (Ex: No records to display) in the table instead of a blank table.  Example code snippet below:

 

 

<apex:repeat var="auditList" value="{!relatedTo.Site_Audit__r}">
   <tr>
    <td>
	<apex:outputField value="{!auditList.Audit_Type__c}" />
    </td>
    <td>
       	<apex:outputField value="{!auditList.Delivery_Date__c}" />
    </td>
    <td>
	<apex:outputField value="{!auditList.Review_Date__c}" />
    </td>
   </tr>
</apex:repeat>

 

Thanks for any help or suggestions! 

 

  • August 09, 2010
  • Like
  • 0
Let's say that one entry of a picklist is defined in the Translation Workbench as follows:

Master value: Hi
Spanish value:Hola
French value: Bonjour

How can I use the metadata API to get the master value from a translated value in a picklist ??
For example: If my only input is "Bonjour" how can I query the Translation Workbench to get "Hi"???

Any idea?
Thanks!

Hi everyone,

 

I started to get the following error message today, everything was working fine and now I can't deploy my classes because the test units fail due to some incorrect signature in the setCurrentPageReference method inside the Test class.

 

I'm getting the following error message:

 

Save error: Method does not exist or incorrect signature: Test.setCurrentPageReference(System.PageReference)

 

Any ideas on what's happening? Can this be related to the Spring '10 upgrade? It's frustrating that this kind of things happen when you're ready to deploy your stuff to production.. 

 

 

 

 

 

 

Hello everyone, I've recieved nothing but great feedback from the autocomplete component I posted previously here in the discussion boards. So here's something else I would like to share with you.

 

Apex Object Merge Class

 

This apex class allows merge operations on a any custom object, please feel free to read more about it here:

 

http://jonathanrm.com/2010/02/force-com-apex-mergereplace-class/

Message Edited by jonathan rico on 02-07-2010 01:54 PM

Hello everyone, I'm trying to override the "Go to list (x)+" link that displays in related list so that It points to a VisualForce page.

 

Overriding the List View for the object in the setup section took care of this, but in order to override the List View I must use a page that is linked to a StandardSetController (using recordSetVar) in order to have it as an available option for override.

 

Everything went fine untill that point.. but 

 

When displaying the records from the  standardset controller I get the list of All of the records and not only the ones from the related list i'm coming from.

 

I supposed this was because there was no way for my VF page to know which are the selected records, or something similar.. so I decided that then I should build my custom related list, but then I noticed that my VF page only recieves a rlid parameter with what I suppose is the id of the child relationship from the parent object.

 

However I don't have the parent Id anymore in the new page and I need this to create my custom set controller in order to get the correct set of records.

What's weird is that if I hover the "Go to list (x)" link I see that the url contains the same rlid parameter and the parent Id, but I'm not sure why the parent Id is removed when overriding the link with visualforce.

 

What would be ideal is that overriding a list view takes care of all of this, and that it knows that it should only display records from the parent object from which i'm coming from. Maybe this is possible and I'm doing something wrong, if this is the case let me know and I'll post my code. 

 

If this is working as designed, then I should build my custom related list but I need to find a way of getting the parent's id in order to limit the set of records.

 

Please let me know if anyone else has bumped into this. If this is working as designed, then what is the real purpose of overriding a List for an Object?

 

Thanks in advance!

Message Edited by jonathan rico on 02-03-2010 02:40 PM
Hello everyone, just wanted to share with the community this custom component I made and give something back for the help I've received. :smileyhappy:

The purpose of the component is to enable autocomplete in lookup fields. I used the autocomplete js created by Jim Roos:
(http://www.jimroos.com/2007/05/ajax-autocomplete.html) but made some modifications to it so that it could interact with an Apex controller among some other things...

So my idea was that if you were making a VF page that had an inputfield that was related to a lookupfield you would just insert this autocomplete component to that inputfield. Something like this:

Code:
           <apex:inputField value="{!Contact.accountid}" id="accname" styleClass="cField">
<c:autocomplete ObjectName="Accounts" InputId="{!$Component.accname}" AutoCompleteId="accACid" ClassName="autocomplete300"/>
</apex:inputField>

The component has 4 parameters:

The name of the object or custom object that the inputfield relates to (new objects must be added inside the apex classes since i had some problems constructing a dynamic query).
The InputId which is used to relate the component to the input field
The id for the Component
A classname parameter that basically just defines the width of the suggestions menu.

Here's a screenshot of how it looks like in action:




Here's a link to the file containing the required files:

AutoCompleteComponent



Jonathan.


Message Edited by jonathan rico on 08-16-2008 01:55 PM

Message Edited by jonathan rico on 08-17-2008 09:04 AM
Message Edited by jonathan rico on 01-02-2010 05:01 PM