Read our blog for the latest insights on sales and marketing Take Me There
Webinar: Enhance Customer Relationships with TrustSphere Register
Webinar: Eliminate Data Silos with Sugar Integrate Register
Webinar: Top 5 Sugar Enhancements From W-Systems Register
In this blog post we explain how to build a dependent alert that displays only when certain criteria are met. This alert could be displayed to bring to a user's attention that an Opportunity is outdated, that a Case has been open longer than acceptable, or that a Quote is expiring. In this specific example we will build a field that alerts users when an Opportunity is outdated.
Here is what the field looks like within Sugar. It will display on an Opportunity only when the expected close date is in the past.
There are three main steps to implement a custom field.
The first step to build this calculated field is to create the field in Sugar Studio. To access Sugar Studio, log into Sugar using an account with administrative privileges. Next, access the admin panel by clicking the top right drop-down arrow in the navigation bar and clicking “Administration”.
Scroll down to the part of the admin page labeled “Developer Tools” and click on “Studio”.
When Studio loads it will display a list of modules you can edit. Click on Opportunities, or if you are using Sugar Enterprise, click on Revenue Line Items. For this example we will be working with the Revenue Line Items module.
Next, select the module component you wish to modify. We want to create a new field, so select “Fields”.
You are now looking at all the existing fields that have been previously built in the Revenue Line Items module. Custom fields that are already built will be marked with an asterisk (*). Click “Add Field” to create a new field.
You are now looking at the field editor. First, select the Data Type to be “HTML”. An HTML field creates static HTML-formatted text to display in record views.
Next, name the field by entering the desired name into “Field Name”. The Field Name cannot contain any spaces or uppercase letters. I named my field “outdated-opp-alert”.
Once you enter your Field Name and click outside of the field, the fields “Display Label” and “System Label” will automatically populate. You may wish to make some adjustments to the “Display Label” field since this will be displayed to users in your system.
Next, use the WYSIWYG editor to create the HTML-formatted text you would to display to your users.The tool allows you to be as creative as you like (you can even add images). We formatted our text to say “This opportunity has an expected close date in the past. Please update the expected close date or change the opportunity status.” and formatted it with large, bold, red text.
Once you are happy with the look of your text, scroll down and tick off the checkbox named “Dependent”. This is what indicates that this field will only display sometimes based on other qualifiers.
Next, we need to enter the factors that determine when the field is visible and when it is not. We will do this by filling out the field “Visible if”. To do this, click the “Edit Formula” button next to the “Visible If” field. This will open up the formula builder. This is the final formula we need to build: “greaterThan(0,daysUntil($date_closed))”. You can simply copy and paste this into the formula builder, or follow the steps below. First, we will use the function “greaterThan”. This function returns true (or will display the field), when the first parameter is greater than the second parameter. The function is entered like this: greaterThan(parameter 1, parameter 2).
For the first parameter, enter “0”
For the second parameter, use the function “daysUntil”. This function is entered as “daysUntil(parameter 1) and counts the number of days until the specified field you insert.
Next, select the field “$date_closed” from the field list. This is the field we want to count the number of days until.
Click “Save” within the formula builder and then again at the top of the page to save the field.
Now click “Revenue Line Item” at the top of the page to navigate back to the editing options.
Click “Layouts” so we can add the field to the layout.
Now click “Record View” so we can add the dependent alert to the record view for Revenue Line Items.
To add the field to the record view, click on “New Row” in the toolbox on the lefthand side of the layout editor, and drag a new row to the layout.
Scroll down within the toolbox and find the field we just created. Drag and drop this field into the filler space we just added.
Click “Save and Deploy” at the top of the editor.
Now we can test the field by navigating to the Revenue Line Items module. On the record below you can see that the expected close date was in the future on the date this blog was published.
When we update the expected close date to be a date in the past, the alert we built is visible. The field works!
We demoed this field in a Sugar Webcast, along with several other custom fields. To check out the full recording, click here.