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
Lee SinLee Sin 

Custom Button URL Hacking Missing Field Name

I am trying to pre-populate a picklist of 'calltype' by using URL hacking.

I have a Replated List of Contacts on Account Layout.

On the Related List, I have a custom button for creating new Activity.

The behavior of the botton is Exucute JavaScript.

I am using URLFOR method to create the url.

In the parameters list,  I am trying to add a default value for the picklist of filed 'calltype'.

I lookedup the ID of that picklist from pagesource to be '00NC0000005FPzF' but it shows error "missing field name" when I checked syntax.

So I tried other ways:

CF00NC0000005FPzF='NML',     no error but the picklist is not prepopulated
Task.00NC0000005FPzF='NML'   no error but the picklist is not prepopulated
NC0000005FPzF='NML',     no error but the picklist is not prepopulated

Why other fields all have names and ids  like 'tsk5' in the pagesource but only calltype  has name and id like '00NC0000005FPzF'?

here's my Js codes:

var recordIds = {!GETRECORDIDS($ObjectType.Contact)}
if(recordIds.length > 1) {
  alert("You must choose no more than one contact to record this voice mail.\n\nPlease check a box next to a contact and try again.")
}
else
{ var retURL = "/001";
  var links = document.getElementsByTagName("a");
  for( var ctr = 0; ctr < links.length; ctr++ ) {
  var href = links[ctr].href
  if( href != undefined && href.match(/\?(fcf|lsr)=/) ) {
    retURL =href
    break
  }
}
var finalHref = "{!URLFOR($Action.Activity.NewTask,null,[what_id=Account.Id,Activities.00NC0000005FPzF="NML",tsk5="NML",tsk12="Completed",tsk4=TEXT(MONTH(TODAY())) &"/" &TEXT(DAY(TODAY())) & "/"&TEXT(YEAR(TODAY()))],true)}"
finalHref = finalHref.replace(/retURL=[%\w\d]+&?/,'')
retURL = escape(retURL.replace(/https?:\/\/.*\.com/,""))
finalHref += (recordIds.length==1?("&who_id="+recordIds[0]):"")+"&retURL="+retURL
  window.top.location.href = finalHref
}

Ashish_SFDCAshish_SFDC
Hi , 


Changing the Salesforce Object ID will not help as it is auto generated and cannot be altered or modified for some other related value - that is completely Unique. 

You can use the get set method via the visualforce page on the javascript action, 

VisualForce Page :
<apex:selectList value="{!PicklistValue}" size="1"  >
<apex:selectOptions value="{!Picklist}"  />
</apex:selectList>

You can populate a picklist field simply by assigning the picklist value string to the field.

t.Status = 'Updated Value';

You can also use a simple workflow to update the field as well. 

See the below links for further information,

https://developer.salesforce.com/forums?id=906F00000008z93IAA

https://developer.salesforce.com/forums?id=906F00000008zTpIAI

https://developer.salesforce.com/forums?id=906F00000008zR8IAI

https://developer.salesforce.com/forums?id=906F00000008xbdIAA

https://developer.salesforce.com/forums?id=906F00000008wiGIAQ

http://salesforce.stackexchange.com/questions/23070/update-a-picklist-value-with-a-text-fields-value-using-workflow


Regards,
Ashish