How do I create a label field that shows a warning or not?

I have an API that returns true or false based on if the id is associated with a course that has been billed.  I needed to create a API, because the billed value is in a  parent module.

How do a create a custom field that is a label that displays a warning message based on a true value?

Thank you

Parents
  • Hi

    Perhaps you may prefer to apply the custom Dependency SetColor.

    Save the code bellow in the file custom/include/Expressions/Actions/SetColorAction.php

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    <?php
    /*
    * Your installation or use of this SugarCRM file is subject to the applicable
    * terms available at
    * http://support.sugarcrm.com/Resources/Master_Subscription_Agreements/.
    * If you do not agree to all of the applicable terms or do not have the
    * authority to bind the entity as an authorized representative, then do not
    * install or use this SugarCRM file.
    *
    * Copyright (C) SugarCRM Inc. All rights reserved.
    */
    /**
    * Class SetColorAction
    *
    * SugarLogic Action to set a color to a field
    */
    require_once("include/Expressions/Actions/AbstractAction.php");
    class SetColorAction extends AbstractAction
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Create the file custom/Extension/<module>/Ext/Dependencies/SetColor.php with content bellow, obviously update it accordingly:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    <?php
    $dependencies['Products']['setcolor'] = [
    'hooks' => ["edit", "view"],
    'trigger' => 'equal($the_field_c, true)',
    'triggerFields' => ['the_field_c'],
    'onload' => true,
    'actions' => [
    [
    'name' => 'SetColor',
    'params' => [
    'target' => 'the_field_c',
    'value' => '"label red"',
    'colors' => 'createList("label red")',
    'errorValue' => '"label red"',
    ],
    ],
    ],
    ];
    ?>
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Run the following repair actions:

    • Quick Repair and Rebuild
    • Rebuild Sugar Logic Functions
    • Rebuild Javascript Languages
    • Rebuild JS Grouping Files
    • Clear Additional Cache

    Finally clear browser cache and enjoy it.

    André Lopes
    Lampada Global
    Skype: andre.lampada
Reply
  • Hi

    Perhaps you may prefer to apply the custom Dependency SetColor.

    Save the code bellow in the file custom/include/Expressions/Actions/SetColorAction.php

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    <?php
    /*
    * Your installation or use of this SugarCRM file is subject to the applicable
    * terms available at
    * http://support.sugarcrm.com/Resources/Master_Subscription_Agreements/.
    * If you do not agree to all of the applicable terms or do not have the
    * authority to bind the entity as an authorized representative, then do not
    * install or use this SugarCRM file.
    *
    * Copyright (C) SugarCRM Inc. All rights reserved.
    */
    /**
    * Class SetColorAction
    *
    * SugarLogic Action to set a color to a field
    */
    require_once("include/Expressions/Actions/AbstractAction.php");
    class SetColorAction extends AbstractAction
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Create the file custom/Extension/<module>/Ext/Dependencies/SetColor.php with content bellow, obviously update it accordingly:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    <?php
    $dependencies['Products']['setcolor'] = [
    'hooks' => ["edit", "view"],
    'trigger' => 'equal($the_field_c, true)',
    'triggerFields' => ['the_field_c'],
    'onload' => true,
    'actions' => [
    [
    'name' => 'SetColor',
    'params' => [
    'target' => 'the_field_c',
    'value' => '"label red"',
    'colors' => 'createList("label red")',
    'errorValue' => '"label red"',
    ],
    ],
    ],
    ];
    ?>
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Run the following repair actions:

    • Quick Repair and Rebuild
    • Rebuild Sugar Logic Functions
    • Rebuild Javascript Languages
    • Rebuild JS Grouping Files
    • Clear Additional Cache

    Finally clear browser cache and enjoy it.

    André Lopes
    Lampada Global
    Skype: andre.lampada
Children
  • You can use the "related" Sugar Logic function in the trigger line of André's code to get the value of the field in the parent module.

  • I just want it to return a message to the screen saying this course has been billed.

    Sorry, I am having trouble understanding what the code is doing in order to translate it to what I need.

    Where would you add the Action to a field?