Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Display message on portal based on condition

abhaysingh98
Tera Contributor

Hello Everyone,

I have a requirement when I open an activity record on portal then a form is opened and under that there are multiple sections/tabs in which I have to show a message (added screenshot) .

 

Actual requirement - 

When activity is in Planning state and all the fields are filled-in (included Classification confirmed if applicable) then it is showed following message on TOP of Planning TAB:

"Planning Phase fields are completed. Please click "Ongoing Activity" button to change the status to Ongoing."

 

I have used client controller and html code but its not working .

 

Client controller -

function($scope, spUtil) {
// Define the fields within the section that need to be filled
$scope.sectionFields = ['section_field1', 'section_field2', 'section_field3'];
$scope.sectionFieldsFilled = false;

// Function to check if all fields in the section are filled
$scope.checkSectionFields = function() {
$scope.sectionFieldsFilled = true;
$scope.sectionFields.forEach(function(field) {
var fieldValue = $scope.data.record[field];
if (!fieldValue) {
$scope.sectionFieldsFilled = false;
}
});
};

// Watch for changes in the form data for the section fields
$scope.$watch('data.record', function(newVal, oldVal) {
$scope.checkSectionFields();
}, true);

// Initialize field check on load
$scope.checkSectionFields();
}

 

HTML -

<div>
<!-- Conditionally display the message if all section fields are filled -->
<div ng-if="sectionFieldsFilled" class="alert alert-info">
All required fields in this section are filled.
</div>
</div>

1 REPLY 1

abhaysingh98
Tera Contributor

can someone please help me to achieve this requirement