function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
jgradw2jgradw2 

Problem with URLFOR using custom objects

Hello! I am looking through the forums and can only find questions about using URLFOR and the "new" action on a custom object. But what about using "edit" or "delete"? For example, I would like to do the following:

<Apex:commandLink action="{!URLFOR($Action.someObject__c.delete, objectID)}" value="Delete" />

 or exchange "delete" for "edit". But whenever I do this, I get the error:

"Visualforce Error


Invalid parameter for function URLFOR"

 

Is there any solution or explanation? Thank you in advance :)

Best Answer chosen by Admin (Salesforce Developers) 
jgradw2jgradw2

Thank you very much! I have figured out my problem. My action commands were directed to the wrong custom object. However, with the delete action, it will direct to the page that has just been deleted! So I will look into a way to re-direct back to the page it was on. Thank you!

All Answers

Big VBig V

I dont think there is a Global Action variable for edit and delete.

But for edit may be you can try this out.

 

<apex:outputlink value="/{!record.id}/e?retURL={!returnurl}"> edit record </apex:outputlink>

 

where record is your record and the returnurl id the page you want to navigate to once save is complete. Returnurl can be any VF pages or simply pass the id of the rcord if you want to return back to detail page of the record or else you can leave it blank as value="/{!record.id}/e" .

 

For delete you may have to write a controller action function.

 

 

 

Big V

jgradw2jgradw2

Thank you very much for your help! To answer your uncertainty, there are global action edit and delete variables. However, I don't think I've done something right... maybe my custom objects need a visualforce page first? Because the URL just does not work...

jgradw2jgradw2

Thank you very much! I have figured out my problem. My action commands were directed to the wrong custom object. However, with the delete action, it will direct to the page that has just been deleted! So I will look into a way to re-direct back to the page it was on. Thank you!

This was selected as the best answer