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
magdamagda 

Detail View Customer Button to change field value of a picklist -- visibility depend on profile

Hi,

I have a customer button in the detail view.
I want to change a field value (for the same object),  if i click this button.

I create this button as : Execute JavaScript
On Click JavaScript
and code:
Code:
{!Object__c.Picklist__c}.set( 'Value');

But it is not running.
Do you have an Idea?

My second Problem is how can i set security on Button? : depend on profile  a button is visible or not visible.

Thx

Magda

thought_currythought_curry

Hi Magda,

I think just setting the value to the field doesnt help.

You need to use AJAX tools to update the object as well and then display the detail page of the object.

The only way i can think of for setting the security for the button is to have a seperate page layout for that profile.

Hope this helps!

 

 

magdamagda
Hi,

what i don't know is:
how can i modify the object i'm seing.
I try this:
Code:
var result = sforce.connection.query("select name, id from Object__c where Object__c.id = {!Object__c.id}");
result[0].Picklist__c = “New Value”
sforce.connection.update([result]);

 

And it is not running.

My Idea is
1 first select in the result my object --> How can I do that?
2 update this object
3 refresh my page --> How can i do that?

Thx

Magda


Message Edited by magda on 02-21-2008 02:54 AM
thought_currythought_curry
This should help for updating
 
var account = new sforce.SObject("Account");
account.id = '{!Account.Id}';
account.Picklist__c = 'New Value';
result = sforce.connection.update([account]);
For refreshing the page
 
window.parent.location.href="{!URLFOR($Action.Account.View, Account.Id,null , true )}";
 
magdamagda
Hi,

thx it is running

;)