8,SFDC 管理员篇 - 数据模型 - 公式和验证 2

时间:2024-01-14 19:05:32
1, Checkbox
只接受真值或者假值
And(arg1, arg2....)至少两个参数,只有参数都为真时候,才返回真,只要有一个为假,就都为假
例如:AND(DoNotCall, HasOptedOutOfEmail)
Or(Arg1, Arg2...)至少有两个参数,参数中只要又都为假的时候才返回假,否则都返回真
例如:OR(Begins(Title, "Chief"), CONTAINS(Title, "President"))
NOT() 为了就是取反,因为对于Checkbox一类控件而言真代表真代表被选中,假代表没被选中
例如:NOT( ISBLANK(FirstName) && ISBLANK(LastName) && ISBLANK(Phone) && ISBLANK(Email) && ISBLANK(MailingAddress) )
有任何一个为控都返回真,然后再由Not转为假
IF(test, result, alternate) 代表test为真 则得到result,否则得到的alternate)
 8,SFDC 管理员篇  - 数据模型 - 公式和验证 2
8,SFDC 管理员篇  - 数据模型 - 公式和验证 2
IF(Is_Executive__c, IF(Department = "Sales", BEGINS(Phone, "(212)"), False), IF(Department = "Marketing", BEGINS(Phone, "(415)"), False))
Checkbox 举例
AND(Probability < 0.5, ExpectedRevenue < 10000)
ISPICKVAL(Priority, "High") && NOT(IsClosed) && (IsEscalated || Days_Since_Last_Update__c >7)
(ISPICKVAL(Priority, "High") && NOT(IsClosed) && IsEscalated)|| Days_Since_Last_Update__c > 7
IF(NOT(DoNotcall), NOT(ISBLANK(Phone)), false)
--------------------------------------------------------------------------------------------------------
2, Numbers, Currency, and Percentages
ROUND(Price__c - Price__c * Discount__c, 2) 小数后面保留两位
例如,计算百分比
IF(Principal__c < 10000, 0.02, IF(Principal__c >= 10000 && Principal__c < 100000, 0.03, 0.04))
例如:计算金额
Principal__c * EXP(Interest_Rate__c * (YEAR(TODAY()) - VALUE(YearStarted)))
资金数* e^(利率*(今年-开始年份))
例如:数字
MIN(500, Sale__c * Commission__c)
--------------------------------------------------------------------------------------------------------
3,Date & Time
转换成日期
DATE(2015, 03, 17)
DATETIMEVALUE("2015-03-17 17:00:00")
DATEVALUE("2015-03-17")
TODAY() - DATEVALUE(CreatedDate)返回距离现在一共又多少天
TODAY() + 3 今天基础上加3天
CASE(expression, case1, result1, case2, result2, ... , else_result)
CASE( MOD(TODAY() - DATE(1900, 1, 7), 7), 当前日期减去1900,1,7 并求余数 3, TODAY() + 2 + 3, 如果是3,则+5 4, TODAY() + 2 + 3, 5, TODAY() + 2 + 3, 6, TODAY() + 1 + 3,如果是6,则+4 TODAY() + 3,如果是其他值,则+3 )
时间举例
IF( MONTH(Date__c) = 12, 如果月份是12 DATE(YEAR(Date__c), 12, 31), 则取年,再配上12月31日 DATE(YEAR(Date__c), MONTH(Date__c) + 1, 1) - 1 )
IF( AND( MONTH(Date__c) = 2, 如果月份是2 DAY(Date__c) = 29,日期是29 NOT( OR( MOD(YEAR(Date__c), 400) = 0, AND( MOD(YEAR(Date__c), 4) = 0, MOD(YEAR(Date__c), 100) != 0 ) ) ) ), DATE(YEAR(Date__c) + Num_Years__c, 3, 1), DATE(YEAR(Date__c) + Num_Years__c, MONTH(Date__c), DAY(Date__c) ) )
--------------------------------------------------------------------------------------------------------
4,PickList
ISPICKVAL(picklist_field, text_value) 如果选取值等于text_value 则返回真,否则返回假
举例
IF(ISPICKVAL(Contract_Status__c, "Activated"), 如果状态为激活 TODAY() - Contract_Activated_Date__c, null) 则今天的日期减去合同时间,否则null
IF(AND(Payment_Due_Date__c < TODAY(), ISPICKVAL(Payment_Status__c, "UNPAID")), "Payment overdue!", null)
--------------------------------------------------------------------------------------------------------
4,Text
FirstName & " " & LastName
IF( AnnualRevenue > 1000000 && 如果营业额大于一百万 CONTAINS(CASE(Country, "United States", "US", "America", "US", "USA", "US", "US", "US", "NA"), "US"), 如果国家以下情况则返回US 为真 IF( ISPICKVAL(LeadSource, "Partner Referral"), "Hot", 如果list选择 是 Partner,则返回hot IF( ISPICKVAL(LeadSource, "PurchasedList") || 否则如果选择PurchasedList 和 web 则返回warm ISPICKVAL(LeadSource, "Web"), "Warm", "Cold" ) ), "Cold" 否则全部返Cold )
显示为图片星星图标
IMAGE(
CASE(Rating__C,
"Hot", "/img/samples/stars_500.gif",
"Warm", "/img/samples/stars_300.gif",
"Cold", "/img/samples/stars_100.gif",
"/img/samples/stars_000.gif"),
"Unknown")