+ Start a Discussion
AntonyasLenAntonyasLen 

System variable | system field

Hi,

 

I wanted to know if it's possible to set a system var/value to use it in all my classes.

I'm thinking about a field who will be a "system field" !

 

******

info:

Special discount (percent)

T is a period of Time (1 month -2 months - 1years who know)

****

 

I have to use this special discount in a lot of case but i don't want to set it "manually" in my classe because i want to allow my CEO to go trought the CRM settings to update this value when he have to do it!

 

Does anyone have any idea?

 

sfdcfoxsfdcfox

Consider a "Custom Setting" (Setup > Develop > Custom Settings). These "custom settings" are statically available (i.e. does not require a query to locate the data), and can be configured in Setup (if the user has "Customize Application" permissions). If you configure it as a heirarchy custom setting, you can additionally allow overrides to the data at the profile and user level.

AntonyasLenAntonyasLen

I set my item and a field called "VAT" and i set a default value.

Now, i was thinking that i just need to create an instance of my object if i want to use my field but it looks to don't work.

 

i was doing like this example :

 

Myitem i = new Myitem();

decimal test = 159 / i.VAT__c;

 

Edit: the value of my field is empty even if i set a default value....=(

sfdcfoxsfdcfox
MyItem__c x = MyItem__c.getOrgDefaults();
decimal test = 159 / x.VAT__c;

// OR

MyItem__c x = MyItem__c.getValue('Default');
decimal test = 159 / x.VAT__c;

The former assumes you're using a heirarchy setting, the latter if you're using a list setting.