(Example) Create an Inline Function

This example shows how to configure various types of functions in the Inline Functions activity.

Background and Setup

Good to Know

  • When you add a function to the Formula field, the value that shows in the parentheses ( ) does not always represent the correct syntax for the function. The examples in this topic provide some of the correct syntax formats.

How to Start

  1. Click App Builder.

    Build Apps screen
  2. On the App Explorer screen, do one of these:
  3. Do one of these:
    • Add an activity:
      1. In Process Builder, in the Activity Library, open the Utilities tab.

        Open Utilities tab
      2. On the Utilities tab, drag the Inline Functions activity onto your process.

        Drag Inline Functions activity
    • Change an activity:
      1. In your process, double-click your activity.
  4. Complete the fields on the General Configuration screen.
  5. Click Next.

    The Inline Functions screen shows.


    Inline Functions screen

Example 1: Sum

This example shows how to configure the Sum function to show the total bill amount of a laptop computer and accessories.

Display Syntax

@Sum(N numbers)

Input Syntax

A comma-separated list of numbers or variables that represent numbers.

@Sum(100,200,300)

Variables must be in xpath format:

@Sum(${/pd:AP/pd:formFields/pd:Variable1},${/pd:AP/pd:formFields/pd:Variable2},${/pd:AP/pd:formFields/pd:Variable3})

Procedure

  1. On the Inline Functions screen, click Add Add icon.

    Inline Functions screen Variables
  2. On the Inline Functions screen, in the Number section, drag the Sum function onto the Formula field.

    Sum Functions
  3. In the Formula field, configure the Sum function.

    You can use literal values in this format:

    @Sum(5000,100,50)


    Inline Functions screen

    You can use variables in this format:

    @Sum(${/pd:AP/pd:formFields/pd:LaptopPrice},${/pd:AP/pd:formFields/pd:WirelessMouse},${/pd:AP/pd:formFields/pd:WirelessKeyboard})


    Inline Functions screen Variables
  4. Click Apply.

    Apply Formula
  5. On the Inline Functions screen, drag the variable onto the Result field.

    This variable shows the output for the Sum function at runtime.


    Result
  6. Click Finish.

Result

After the process completes, you can view the result in Manage Center on the Process Detail screen > Data tab > Form Variable tab.


Inline Functions Result

The value for the TotalBillAmount variable shows the result of the Sum function.

Example 2: Average

This example shows how to configure the Average function to show the average grade for a student.

Display Syntax

@Avg(N numbers)

Input Syntax

A comma-separated list of numbers or variables that represent numbers.

@Avg(100,200,300,400)

Variables must be in xpath format:

@Avg(${/pd:AP/pd:formFields/pd:Variable1},${/pd:AP/pd:formFields/pd:Variable2},${/pd:AP/pd:formFields/pd:Variable3}, ${/pd:AP/pd:formFields/pd:Variable4})

Procedure

  1. On the Inline Functions screen, click Add Add icon.

    Inline Functions screen Variables
  2. On the Inline Functions screen, in the Number section, drag the Average function onto the Formula field.

    Sum Functions
  3. In the Formula field, configure the Average function.

    You can use literal values in this format:

    @Sum(90,98,82,86)


    Inline Functions screen

    You can use variables in this format:

    @Avg(${/pd:AP/pd:formFields/pd:English},${/pd:AP/pd:formFields/pd:Maths},${/pd:AP/pd:formFields/pd:Physics},${/pd:AP/pd:formFields/pd:Chemistry})


    Inline Functions screen Variables
  4. Click Apply.

    Apply Formula
  5. On the Inline Functions screen, drag the variable onto the Result field.

    This variable shows the output for the Average function at runtime.


    Result
  6. Click Finish.

Result

After the process completes, you can view the result in Manage Center on the Process Detail screen > Data tab > Form Variable tab:


Inline Functions Result

The value for the AverageScore variable shows the result of the Average function.

Example 3: DateDiffDays

This example shows how to configure the DateDiffDays function to show the number of days that expired to complete a task.

Display Syntax

@DateDiffDays(StartDate, EndDate)

Input Syntax

Two strings or variables that represent a start date and end date, separated by a comma.
  • Date values must be enclosed by quotation marks.
  • Date values must be in the format MM/dd/yyyy.

@DateDiffDays("09/25/2019", "03/31/2020")

Variables must be in xpath format:

@DateDiffDays(${/pd:AP/pd:formFields/pd:Date1}, ${/pd:AP/pd:formFields/pd:Date2})

Procedure

  1. On the Inline Functions screen, click Add Add icon.

    Inline Functions screen Variables
  2. On the Inline Functions screen, in the Date section, drag the DateDiffDays function onto the Formula field.

    Sum Functions
  3. In the Formula field, configure the DateDiffDays function.

    You can use literal values in this format:

    @DateDiffDays("03/01/2020", "03/19/2020")


    Inline Functions screen

    You can use variables in this format:

    @DateDiffDays(${/pd:AP/pd:formFields/pd:SubmittedDate}, ${/pd:AP/pd:formFields/pd:ApprovalDate})


    Inline Functions screen Variables
  4. Click Apply.

    Apply Formula
  5. On the Inline Functions screen, drag the variable onto the Result field.

    This variable shows the output for the DateDiffDays function at runtime.


    Result
  6. Click Finish.

Result

After the process completes, you can view the result in Manage Center on the Process Detail screen > Data tab > Form Variable tab:


Inline Functions Result

The value for the NumberOfDaysToApprove variable shows the result of the DateDiffDays function.

Example 4: AddTicks

This example shows how to configure the AddTicks function to add one second to the date time value.

Note: 1 sec. = 10,000,000 ticks

Display Syntax

@AddTicksToDate(Date, Number)

Input Syntax

A string or variable that represents the date-time, followed by the number of ticks, separated by a comma.
  • Date values must be enclosed by quotation marks.
  • Date values must be in the format MM/dd/yyyy HH:mm:ss.

    If you do not give the time value, the time value is assumed to be 12:00:00 a.m.

  • The value for ticks must not have commas.

@AddTicksToDate("02/25/2020", 30200100)

Variables must be in xpath format:

@AddTicksToDate(${/pd:AP/pd:formFields/pd:Date1}, ${/pd:AP/pd:formFields/pd:Variable})

Procedure

  1. On the Inline Functions screen, click Add Add icon.

    Inline Functions screen Variables
  2. On the Inline Functions screen, in the Date section, drag the AddTicks function onto the Formula field.

    Sum Functions
  3. In the Formula field, configure the AddTicks function.

    You can use literal values in this format:

    @AddTicksToDate("02/15/2020 20:35:44", 10000000)


    Inline Functions screen

    You can use variables in this format:

    @AddTicksToDate(${/pd:AP/pd:processFields/pd:SubmittedDate}, ${/pd:AP/pd:formFields/pd:NumberofTicks})


    Inline Functions screen Variables
  4. Click Apply.

    Apply Formula
  5. On the Inline Functions screen, drag the variable onto the Result field.

    This variable shows the output for the AddTicks function at runtime.


    Result
  6. Click Finish.

Result

After the process completes, you can view the result in Manage Center on the Process Detail screen > Data tab > Form Variable tab:


Inline Functions Result

The value for the SubmittedDateWithTicks variable shows the result of the AddTicks function.

Example 5: XmlEncode

This example shows how to configure the XmlEncode function to change XML markup to Unicode characters for process, storage, and data interchange of text data.

Display Syntax

@XmlEncode(SourceString)

Input Syntax

A string or variable that represents the XML code.
  • A well-formatted XML code snippet without headers or spaces.
  • The XML code must be enclosed by quotation marks.

@XmlEncode("<order><name>office paper</name><price>$10</price> <quantity>3</quantity></order>")

Variables must be in xpath format:

@XmlEncode(${/pd:AP/pd:formFields/pd:Variable})

Procedure

  1. On the Inline Functions screen, click Add Add icon.

    Inline Functions screen Variables
  2. On the Inline Functions screen, in the Text section, drag the XmlEncode function onto the Formula field.

    Sum Functions
  3. In the Formula field, configure the XmlEncode function.

    You can use literal values in this format:

    @XmlEncode("<order><requester>John</requester><name>Laptop Computer</name><price>$1500</price> <quantity>1</quantity><ram>8 GB</ram><processor>Core i7-2600</processor><hdd>1 TB</hdd></order>")


    Inline Functions screen Variables

    You can use variables in this format:

    @XmlEncode(${/pd:AP/pd:formFields/pd:OrderXML})


    Inline Functions screen Variables
  4. Click Apply.

    Apply Formula
  5. On the Inline Functions screen, drag the variable onto the Result field.

    This variable shows the output for the XmlEncode function at runtime.


    Result
  6. Click Finish.

Result

After the process completes, you can view the result in Manage Center on the Process Detail screen > Data tab > Form Variable tab:


Inline Functions Result

The value for the EncodedValue variable shows the result of the XmlEncode function.