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
SFDC coderSFDC coder 

How to implement url hacking?

hi all ,

i have xyz related list on an account record.
i'll be creating a "new button" for that related list.

Problem:
However,through standard new button,it displays the record type select record type page.
How do i achieve this through my custom button?

Thanks
Best Answer chosen by SFDC coder
Gil GourévitchGil Gourévitch
ok, I thought that you wanted to bypass the select record type page, sorry.
Your custom button must go to "/setup/ui/recordtypeselect.jsp?ent=Account&retURL=%2F001%2Fo&save_new_url=%2F001%2Fe%3FretURL%3D%252F001%252Fo"
If you want to pass extra params : go to the standard new page, and check the document source : on chrome, right-click on the field to pre-populate, and select "inspect element", then copy the "id" value :

User-added image

In your url, add : ".....&acc23=NEW_VALUE", your field will be pre-populated.
If the field is a lookup field, add "FIELDID=RELATED_RECORD_NAME&FIELDID_lkid=RELATED_RECORD_NAME"
for example for a contact lookup field : ".....accXX=John+Doe&accXX_lkid=003YYYYYY"

Hope this helps
Gil

Question Solved ? Please mark as the best answer to help other users !

All Answers

Gil GourévitchGil Gourévitch
Hi,
This means that you want to create always the same type of object, if this is really what you want :

- Create a custom button of URL type, to override the standard New button (this is a button on "xyz" object).
- Select a recordtype id : go to the record type page, then select the Salesforce ID of the record type : it is the URL portion of the page that starts with 012 :

User-added image

- Paste this url in the button :
"/001/e?retURL=%2F001%2Fo&RecordType=RECORD_TYPE_ID"

- replace the standard New button in the acount page layout, in the related list of xyz object

Hope this helps
Gil

Question Solved ? Please mark as the best answer to help other users !
SFDC coderSFDC coder
hi gil,

thnks for your reply.
but unfortunately,this wont work as i have to pass a fields value to the field of xyz object.
Also this record type id will of only one particular type whereas i want the user to create xyz records of any reocrd types
Is there any other way you know?

thanks
Gil GourévitchGil Gourévitch
ok, I thought that you wanted to bypass the select record type page, sorry.
Your custom button must go to "/setup/ui/recordtypeselect.jsp?ent=Account&retURL=%2F001%2Fo&save_new_url=%2F001%2Fe%3FretURL%3D%252F001%252Fo"
If you want to pass extra params : go to the standard new page, and check the document source : on chrome, right-click on the field to pre-populate, and select "inspect element", then copy the "id" value :

User-added image

In your url, add : ".....&acc23=NEW_VALUE", your field will be pre-populated.
If the field is a lookup field, add "FIELDID=RELATED_RECORD_NAME&FIELDID_lkid=RELATED_RECORD_NAME"
for example for a contact lookup field : ".....accXX=John+Doe&accXX_lkid=003YYYYYY"

Hope this helps
Gil

Question Solved ? Please mark as the best answer to help other users !
This was selected as the best answer
SFDC coderSFDC coder
hi gil,

this is my url

https://xx18.salesforce.com/setup/ui/recordtypeselect.jsp?ent=01I20000000SUSG&retURL=%2F0012000001Duoz3&save_new_url=%2Fa07%2Fe%3FCF00N20000009GubC%3DBlack%2BLion%26CF00N20000009GubC_lkid%3D0012000001Duoz3%26retURL%3D%252F0012000001Duoz3

how do i implement?


Gil GourévitchGil Gourévitch
With this url, create a custom URL button (Setup / Create / XYZ_Object, then Buttons, Links, Actions / New Button)
- Select list button type w/o checkboxes, and URL content source.
- Paste your URL in the textarea, then save.
- add the new button to the account page layout : in the XYZ related list, click on the tool icon on the right, and in the popup, click on the "buttons" section.

Hope this helps
Gil

Question Solved ? Please mark as the best answer to help other users !
SFDC coderSFDC coder
hi gil,
thanks for your reply...i just searched for the id in ent parameter and found out that its my XYZ custom object id so i wrote
ent=XYZ__c howeever i get an error stating that 

The value of the "ent" parameter contains a character that is not allowed or the value exceeds the maximum allowed length. Remove the character from the parameter value or reduce the value length and resubmit. If the error still persists, report it to our Customer Support team. Provide the URL of the page you were requesting as well as any other related information.

can u pls help?


Gil GourévitchGil Gourévitch
You can find the object Id here : setup / create / object and by selecting the ID in URL :

User-added image

Hope this helps
Gil

Question Solved ? Please mark as the best answer to help other users !
SFDC coderSFDC coder
but it would fail when moving to production env so i was trying to write ent=XYZ__c
Gil GourévitchGil Gourévitch
Yes, this is a problem with all url hackings, and this is why it is called "hacking" : as it is based on ID, you must change it while deploying on production.
To avoid this, you can create/refresh a sandbox so your objects, record types etc will have the same ids in production and in sandbox.
I think you will not have so much changes to do after deploy : you can deploy, adapt to prod id, and refresh your sandbox
Be careful, if you refresh a sandbox, all your developments, customizations and test data will be lost.

Hope this helps
Gil

Question Solved ? Please mark as the best answer to help other users !
SFDC coderSFDC coder
hi gil,

thanks for all your replies..BTW this is solved now

below is my code

{!REQUIRESCRIPT("/soap/ajax/22.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/22.0/apex.js" )}

var connection = sforce.connection;
new_url = "{!URLFOR( $Action.Child__c.New, null, [CF00N20000009GubC=Account.Name, CF00N20000009GubC_lkid=Account.Id,CF00N20000009GucF= Account.Account__c,CF00N20000009GucF_lkid=Account.AccountId__c])}";
window.location.replace(new_url);

some way or the other your replies did help me so marking one of them as best answer
Gil GourévitchGil Gourévitch
Glad to help you, and thank you for marking the best answer.

Gil
SFDC coderSFDC coder
hi gil ,

i have a scenario where in i need to prepopulate a field eventId of type text with event object's id passed using URLFOR().
However i get an error saying

Syntax error. Found '[' 

below is my code1 new_url = "{!URLFOR( $Action.Order__c.New, null, [00N11000000srcf=Event.Id])}";

2 window.location.replace(new_url);where  00N11000000srcf is fetched after i right click on text field-->inspect element and copy the id  of the field to be prepopulated

any help is appreciated