Error message on UI Action

Abhishek Pande2
Giga Expert

Requirement: When user click on UI action ' Submit for ST signoff' it should do a validation on Application Service [cmdb_ci_service_auto] Table to validate that business service 'environment is set to 'Production' if not then throw error like 'Can't be signoff since B_App_service is not configured for production".

Which solution will be better and how to implement it? Any leads will be helpful.

find_real_file.png

Abhishek Pandey
+91 7869881249 || 120591abhishek@gmail.com
10 REPLIES 10

Hey,

First things first,

Application services is a related list, you can't dot walk to fetch its information unfortunately.

You need to glide Application Service table here then check for your value.

Since the table is custom table, not sure how the relationship between custom table and application service is established but what you can do here is to Glide the "cmdb_ci_service_auto" table then check for the value.

What is u_operatoion_st_1, u_operatoion_st_1_1 and u_sd_st_2 field and on which table?

Best Regards
Aman Kumar

Hi @Aman Kumar 

Thanks for the response!

Are you suggesting to glide UI action? To add here, the validation is already there in system for portal view and it's working like it will not allow user to submit for signoff till business service is created for business application though it's not working for platform view. 

I am trying here to do similar validation as per portal view on platform view that will not allow user to submit the service transition created if production business service is missing.

  • u_operational_st_1
  • u_operational_st_1_2
  • u_sd_st_2

These are the column name(Field name) on Service Transition[u_service_transition] table.

Regards

Abhishek Pandey

Abhishek Pandey
+91 7869881249 || 120591abhishek@gmail.com

Hey Abhishek,

Can you share, how exactly you are validating this on the portal side?
You can reuse that script to validate that in UI action.

What I was suggesting in my previous reply, since the Application service on the form is not directly available on the table where your UI action is but in the form of related list, so if you want to validate those records, you will need to glide App service table, then take it forward with actions that you want to perform.

So what actually you need to add in your UI action, is to glide app serv table, then check if the value Production is present or not(you will find references how to glide a table using GlideRecord).

And then you can use it to show error message on the form.

 

Best Regards
Aman Kumar

Hi @Aman Kumar 

Thanks for sharing the input. I have tried to do the GlideRecord but it's not working. below is the code for reference if you can help what i am doing wrong [I don't have much understanding of js]

As an alternative is it possible if I can add condition for environment validation for production so that 'Submit For ST Signoff' ui action will be available only when condition match otherwise don't show up at all.

find_real_file.png

function SubmitForSTsignoff(input)
{
	{
		gsftSubmit(null,g_form.getFormElement(),'sys_STsignoff');
	}
if(input)
	{
		if (input.table == "u_service_transition") 
		{
			var grUST = new GlideRecord('u_service_transition');
			if (grUST.get(input.sys_id)) 
			{
				
				if (grUST.getValue("u_business_application")) 
				{
					var grCCSA = new GlideRecord('cmdb_ci_service_auto');
					grCCSA.addEncodedQuery("u_business_application=" + grUST.getValue("u_business_application"));
					grCCSA.query();
					while (grCCSA.next()) 
					{
						if (grCCSA.getValue('environment') == "production")
						gs.addInfoMessage('The Service Transition record can be submitted for signoff only when the respective Application-Service for Production record is created');
                        action.setRedirectURL(current);
					}		
				}
			} 
			
/*else {
		var grCCSA = new GlideRecord('cmdb_ci_service_auto');
		grCCSA.addEncodedQuery("u_business_application=" + input.application_id);
		grCCSA.query();
		while (grCCSA.next()) 
		{
		if (grCCSA.getValue('environment') == "production")
		data.showSignOffButton = true;
    }*/
     }
   }
}

if (current.u_operational_st_1 == 'yes'||current.u_operational_st_1_1 == 'yes') {
    current.u_operations_status = 'pending';
    current.u_st_status = 'pending_signoff';
} else {
    current.u_operations_status = 'na';
}

if (current.u_sd_st_2 == 'yes') {
    current.u_sd_status = 'pending';
    current.u_st_status = 'pending_signoff';
} else {
    current.u_sd_status = 'na';
}
	
current.update();

 

Appreciate your time and effort with this help!

Thanks

Abhishek Pandey

Abhishek Pandey
+91 7869881249 || 120591abhishek@gmail.com

Abhishek Pande2
Giga Expert

Hi @Mohith Devatte 

Can you assist me with this and help me to fix the logic here.

Thank you!

Abhishek Pandey
+91 7869881249 || 120591abhishek@gmail.com