For  referral status icons

Chapter - 08

Visit to buy the book on Citizen Development https://go.citizendeveloper.codes/buynow

Code Snippet #1

For referral status icons

This code snippet display different icons based on the referral status

    Switch(
        ThisItem.'Referral Status',
        'Referral Status (Referrals)'.'Referral bonus settled',
        Icon.Money,
        'Referral Status (Referrals)'.'Admission team support needed',
        Icon.Support,
        'Referral Status (Referrals)'.'Referral bonus unlocked',
        Icon.Unlock,
        'Referral Status (Referrals)'.'Referral code shared',
        Icon.Key,
        Icon.LogJournal
    )

Explanation

This code snippet uses the Switch function, which is a way to handle multiple conditional cases. This function is typically used to evaluate an expression and return different results based on the value of that expression.

  • Switch Function:- The Switch function evaluates an expression and then returns a result depending on the value of that expression. It works similarly to a series of If statements, but is often more concise and easier to read.

  • ThisItem.’Referral Status’:- This ThisItem.'Referral Status' expression evaluates referral status. ThisItem refers to the current item in a collection or data source, particularly when used in a gallery, form, or other data-bound control. 'Referral Status' is a field in the current item.

  • Cases in the Switch Function:- The Switch function then checks the value of ThisItem.'Referral Status' against several possible values. Each case is a value that 'Referral Status' might have, followed by the result that should be returned if that case matches.
    • If the status is 'Referral Status (Referrals)'.'Referral bonus settled', it returns Icon.Money.
    • If the status is 'Referral Status (Referrals)'.'Admission team support needed', it returns Icon.Support.
    • If the status is 'Referral Status (Referrals)'.'Referral bonus unlocked', it returns Icon.Unlock.
    • If the status is 'Referral Status (Referrals)'.'Referral code shared', it returns Icon.Key.
  • Default Case:- The last value in the Switch function (Icon.LogJournal) is the default case. If ThisItem.'Referral Status' does not match any of the specified cases, the function returns Icon.LogJournal.

In summary, this code snippet is used to display different icons based on the referral status of the current item in a data set. It’s a concise and effective way to handle multiple conditions, making it easier to manage and read compared to multiple nested If statements. This is particularly useful in user interface scenarios where you want to visually represent the status of items in a list or gallery.

Happy #low-code learning

Visit: www.citizendeveloper.codes

Id: Chapter-08-CS00001

Category: Chapter 08

Dr. Amit Puri, Advisor and Consultant, Strengthening Digital Experiences, Modernize Cloud Journey with AI-Driven Transformation!