• AndrewX
  • NEWBIE
  • 45 Points
  • Member since 2008

  • Chatter
    Feed
  • 1
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 11
    Replies

I am trying to figure out how to concatenate strings in SalesForce Apex code.  I do not see it anywhere in string methods and as far as I can tell, its not possible.  Am i crazy here?  Is something as simple as string concatenation not available in SalesForce?

 

Thanks

Not sure if this is the correct discussion board...

 

I wrote a trigger, then I wrote a test class with unit tests.

 

Now I want to rename the trigger file and the test class file. I tried from within the Eclipse IDE selecting 'Refactor/Rename...' but it told me that I can't do that from the IDE, but must do it from Salesforce.com. This isn't true because I can't in fact rename those objects from within Salesforce.com

 

So then I thought I can just delete both the trigger and test file and then recreate them. So I select 'Delete' from within Eclipse and when it asks if I want to delete it from the server too I said yes. But in both cases, (trigger and class file) the delete is failing.

 

Please help anyone.

Hi All,

Is there a way around the error 'DML not supported for Folder' in a testMethod? This is being a real problem for me because it's preventing me from getting the 75% coverage I need for this class.

One thing I tried is using test code that tries to find one existing Folder object and using that. Like this:

        Folder[] folder = [SELECT Id FROM Folder LIMIT 1];

This works in development, but when I install the package that this code belongs to, I get this error mesage, and the install fails:

System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, field integrity exception: FolderId (invalid folder): [FolderId]

Any help would be appreciated.

 

Andrew

Hi All,

 

In a previous post, I pointed out a bug in the url that Salesforce generates for my custom Visualforce page. I never got any acknowledgement that this is indeed a bug, or that it is being fixed.

 

I am now finding the same error but in reverse. Before it was putting my namespace prefix in the url when it shouldn't. I was able to find a workaround for that. See my previous post for a detailed description of the error.

 

But now, it's putting c.na2.visual.force.com/apex/MyPage instead of my_namespace.na2.visual.force.com/apex/MyPage. And I am getting 'Page MyPage does not exist' errors, and this time there is really no effective workaround short of hardcoding the url in my Apex code.

 

So, now I don't know if it's a bug or is it my code that is in error.

 

Any feedback would be welcome.

 

- Andrew

Hi,

I have overridden the Standard Delete link on my Custom Object with a custom visual force page. When I click the 'Del' link in a related list of my Custom Object, it shows my custom delete page correctly. However, the retURL parameter that Salesforce injects for the page differs between the Developer Edition and Production environments:

 

In Developer Edition it's this:
&retURL=/0018000000XXXXX

In Production it's this:
&retURL=/apex/AccountDetail?id=0014000000XXXXX

This difference wouldn't normally be a problem, but this code is part of a custom app with a namespace prefix. I have a cancel button on my custom vf page, and when the user hits this cancel button, I navigate to the retURL. In Dev Edition the retURL works fine; in Production, i get an error.

Here's the problem:

The fully resolved url doesn't work in Production. Here it is:

https://my_ns_prefix.na2.visual.force.com/apex/AccountDetail?id=0014000000XXXXX&sfdc.override=1
 
As you can see, it prepends my app's namespace prefix to the url instead of the normal c.na2.visual.force.... and I get the following error:

URL No Longer Exists
You have attempted to reach a URL that no longer exists on salesforce.com.  

Can anyone suggest a work around?

 

Hi All,

How do I access the setting (checked or unchecked) for 'View All' And 'Modify All' for a particular Custom Object?

 

On the Edit Profile page, there is a section where I set the permissions that profile has on a Custom Object. Besides, 'Read', 'Create', 'Edit' and 'Delete', there is a checkbox for 'View All' and 'Modify All'.

 

I am able to read the values for 'Read', 'Edit', 'Create' and 'Delete' in Apex with a call like this:

 

Schema.DescribeSObjectResult objectDescription = CustomObj__c.sObjectType.getDescribe();
objectDescription.isCreateable();

 

but I couldn't find a way read the values for 'View All' and 'Modify All'. Is there a method on DescribeSObjectResult that I am not seeing?

 

Thanks for any help.

 Andrew

 

 

 

Hi All,

 

I am trying to figure out if it's possible to create a polymorphic Lookup custom field (like the WhatId field in Task, where the Id value can point to different types of objects). It looks like it is not possible to modify a Lookup field's metadata directly.

 

Before I expend the time to create a .NET soap client (to run during setup of my custom app), can anyone advise me if it is possible to do this through the Metadata API? Can I pass a string array to the referenceTo field of a Field object... something like that?

 

Thanks for any help,

Andrew

 

 

I have a small form with an <apex:inputFile> in which I am trying to upload an attachment.

 

<apex:form id="form_Upload">
<apex:inputFile id="file_File" value="{!fileBody}" filename="{!fileName}" size="60"/>
<apex:commandButton id="button_Upload" value="Upload"

onclick="if (!validateUploadForm())return" action="{!processUpload}" />
</apex:form>

 

Because I have an onclick JavaScript handler specified for the commandButton, the "action" never occurs (i.e. the Ajax call that would normally be inserted into the onclick never gets inserted) so my HTML source says ony onclick="if (!validate etc...)".

 

I've found that the way to solve this is to add a rerender="" attribute to the commandButton. Since I don't need to rerender anything, I created an empty outputPanel, and added that to the rerender of the commandButton like this:

 

<apex:commandButton rerender="panel_Empty" ... />

 

Well that fixed the problem, because now the generated onclick for the commandButton called my JavaScript onclick then called the Ajax submit method. So far so good....

 

The problem is that when I run this page, I get a runtime error that says that the <apex:inputFile> cannot be used with a commandButton that specifies a rerender attribute.

 

Is this deliberately like this, or is it a bug?

 

Thanks,

Andrew

 

 

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

Hi All,

I have a custom object which allows file attachments. The page layout allows me to put a Related List on the page so users can upload attachments. The problem is that items on the Attachment related list always show three buttons: Edit | Delete | View. I don't want sales rep users to be able to delete these attachments, so I would like to have the Delete link removed or to have it show a 'not enough permission' message when it's clicked by users in the sales role.

I don't know if there is a standard solution to this. I've been searching the documentation and the discussion boards for hints, but haven't found any answers. My first attempt was to create an s-control with javascript and drop it on the page layout, but then I found out after many hours of frustration that s-controls can't reference html elements on the page (this fact should be documented somewhere). I am about to create my own Apex Page to display the detail of this custom object, but I am not even sure that this will accomplish what I want since I am new to SalesForce and Apex coding.

Any help would be appreciated.

Andrew

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

Not sure if this is the correct discussion board...

 

I wrote a trigger, then I wrote a test class with unit tests.

 

Now I want to rename the trigger file and the test class file. I tried from within the Eclipse IDE selecting 'Refactor/Rename...' but it told me that I can't do that from the IDE, but must do it from Salesforce.com. This isn't true because I can't in fact rename those objects from within Salesforce.com

 

So then I thought I can just delete both the trigger and test file and then recreate them. So I select 'Delete' from within Eclipse and when it asks if I want to delete it from the server too I said yes. But in both cases, (trigger and class file) the delete is failing.

 

Please help anyone.

Hi All,

Is there a way around the error 'DML not supported for Folder' in a testMethod? This is being a real problem for me because it's preventing me from getting the 75% coverage I need for this class.

One thing I tried is using test code that tries to find one existing Folder object and using that. Like this:

        Folder[] folder = [SELECT Id FROM Folder LIMIT 1];

This works in development, but when I install the package that this code belongs to, I get this error mesage, and the install fails:

System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, field integrity exception: FolderId (invalid folder): [FolderId]

Any help would be appreciated.

 

Andrew

Hi All,

 

In a previous post, I pointed out a bug in the url that Salesforce generates for my custom Visualforce page. I never got any acknowledgement that this is indeed a bug, or that it is being fixed.

 

I am now finding the same error but in reverse. Before it was putting my namespace prefix in the url when it shouldn't. I was able to find a workaround for that. See my previous post for a detailed description of the error.

 

But now, it's putting c.na2.visual.force.com/apex/MyPage instead of my_namespace.na2.visual.force.com/apex/MyPage. And I am getting 'Page MyPage does not exist' errors, and this time there is really no effective workaround short of hardcoding the url in my Apex code.

 

So, now I don't know if it's a bug or is it my code that is in error.

 

Any feedback would be welcome.

 

- Andrew

Hi,

I have overridden the Standard Delete link on my Custom Object with a custom visual force page. When I click the 'Del' link in a related list of my Custom Object, it shows my custom delete page correctly. However, the retURL parameter that Salesforce injects for the page differs between the Developer Edition and Production environments:

 

In Developer Edition it's this:
&retURL=/0018000000XXXXX

In Production it's this:
&retURL=/apex/AccountDetail?id=0014000000XXXXX

This difference wouldn't normally be a problem, but this code is part of a custom app with a namespace prefix. I have a cancel button on my custom vf page, and when the user hits this cancel button, I navigate to the retURL. In Dev Edition the retURL works fine; in Production, i get an error.

Here's the problem:

The fully resolved url doesn't work in Production. Here it is:

https://my_ns_prefix.na2.visual.force.com/apex/AccountDetail?id=0014000000XXXXX&sfdc.override=1
 
As you can see, it prepends my app's namespace prefix to the url instead of the normal c.na2.visual.force.... and I get the following error:

URL No Longer Exists
You have attempted to reach a URL that no longer exists on salesforce.com.  

Can anyone suggest a work around?

 

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

I am trying to figure out how to concatenate strings in SalesForce Apex code.  I do not see it anywhere in string methods and as far as I can tell, its not possible.  Am i crazy here?  Is something as simple as string concatenation not available in SalesForce?

 

Thanks

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