+ Start a Discussion
PCRecyclerPCRecycler 

Not a programer and need help!

I'm trying to create a simple charging button or script that will apply a numerical value to a field based on text in another field.

 

I'm not a programmer at all but this is so simple i hopping i can figure it out on my own without having to get some outside help.

 

We are using Group Edition and this applies to a custom object.

 

the script is for a button, but ideally i would like this action to take place when the record is created.

 

This is what we have:

 

CASE(Inventory__c.Type__c, "Computer",2.50, "Monitor",7.50, 0)

 

The Type field has several different text optionsI started with just two "Computer" and "Monitor".  the idea is that if these values show up on the type field the numerical value will then show up in a field called charges (Charges__c). 

 

Any help would be great!

Best Answer chosen by Admin (Salesforce Developers) 
zen_njzen_nj

You should be able to just create a custom formula field and then use that field instead. This way whenever your value changed in the origin text field (i.e. Type), salesforce will automatically update this new custom formula field.

 

So you would define a new field to be formula field and have it defined as a number (8,2) or something like that.

Then in defining your formula, you would use the logic you have below:

CASE(Inventory__c.Type__c, "Computer",2.50, "Monitor",7.50, 0)

 

You can then choose to have this custom formula field displayed on your page layout for your Inventory object, but you will notice two things:

1. this field is only read-only - this is because it's a formula field (so value is derived off something else)

2. When you are creating/editing an Inventory entry, this formula field will not be visible. But once you've saved your

    change and are just viewing the entry, you'll see this formula field.  And this formula field will be available as a field in

    Reports if you wanted to run reports and based criteria of this formula field.