How to use the Advanced Formula in the function Attribute?

Updated on February 25, 2020 06:22AM by Admin

If-else statements are usually used for condition-based functionalities. It is used to depict true or false conditions. If a particular condition is true or false, then the subsequent function will work. If not, the else function will work.

Let us consider, you want to get the Billing Price for a product as a separate attribute depending on the Price and the Standard Cost of the product in Items App.

  • Login and access the Items App from the Universal Navigation Bar
  • Click on the More icon (...) and select the Settings.
Settings

  • Click on the Customize App drop-down from the left panel and select Master Layout.
Master Layout

  • Select the Function Attribute from the Right side Palette and drop anywhere in the form.
Function attribute

  • Then, click on the Function attribute to navigate to the Inspector Tab. Here, you can rename the Attribute as Billing Price.
Inspector Tab

For instance: We want to print the cost of the product under the condition based on Price(MRP) and the Standard cost(Selling Price) of the Product. In the Billing Price attribute, set the condition as If the Standard Cost is Lesser than the Price then, print the Standard Cost or else the value should get reduced by 5% from the Price.

To set the If-else statement, Please follow the steps.

Steps to follow

  • Under the Inspector Tab - For the if-else function, the Custom Type should be in Numeric Formula.
Numeric Formula

  • Then, Scroll down the Inspector Tab and click on the Create Function.
Create Function

  • In the Function Editor, Click on the Advanced Tab.
Advanced Tab

  • Type the Function Name as per your preference. Here, naming it as Billing Price Function.
Function Name

  • In the Depends On Filed, select the attributes that depend on this function from the Insert Attributes Filter right above the filed. For Instance: select the attributes, Price and the Standard Cost.
Depends On

  • In the Function Body, you can start entering the if-else condition. In the conditions, you can select the attributes name from the Insert Attribute filter right above the Function body.
  • Condition:
                 if( Price > Standard Cost) {

                 return ( Standard Cost );

                 } else {

                 return ( Price - Standard Cost*5/100 );
                 }

  • Then click on the Create button at the bottom of the Function Body.
Function body

  • Save the changes.
Save Changes

  • You can view the changes in the Create Item Page. In the below slide, the Standard Cost is lesser than the Price, so Price will get updated in Billing Price Field.
Function

  • You can view the changes in the Create Item Page. In the below slide, the Standard Cost is lesser than the Price, so Price will get updated in Billing Price Field.
else Function