If requested for and owner field's values don't match then show new variable

Bindhu1
Tera Contributor

Hi Team, could you please assist here:


If the 'requested for' and 'site owner' variable's values don't match, then display a mandatory upload button with 'xyz' text?

here both the variables refers to user table.

 

Thanks

1 ACCEPTED SOLUTION

Hi @Bindhu1 ,

 

Before submitting the catalog item request will not be created so what you can do is You can compare with logged in user  and site owner because Request table Request for hold the logged in user value,

 

I have changed the client script please have a look,

 

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading || newValue == '') {
	g_form.setDisplay('attachment',false);
      return;
   }

   var requestedFor = g_user.userID;
//    alert('Requested for' + requestedFor);
//    alert('new Value'+ newValue);

   if(requestedFor != newValue){
	g_form.setDisplay('attachment',true);
	g_form.setMandatory('attachment',true);
   }
   else{
	g_form.setMandatory('attachment',false);
	g_form.setDisplay('attachment',false);
	
   }

   //Type appropriate comment here, and begin script below
   
}

 

 

Please mark this comment as Correct Answer/Helpful if it helped you.

Regards,

Swathi Sarang

View solution in original post

12 REPLIES 12

SAI VENKATESH
Tera Sage
Tera Sage

Hi @Bindhu1 

 

Instead of creating a button you can use attachment option in incident table.

By writing business rule before insert or update(based upon your requirements ) we can make attachment mandatory

var currentuser = gs.getUserID();
var caller_id = current.caller_id;

if (currentuser != caller_id) {
    if (current.hasAttachments() == true) {
        gs.addInfoMessage('There is an attachment');
    } else {
        gs.addErrorMessage('There is no attachment');
        current.setAbortAction(true);
    }
}

 

Thanks and Regards

Sai Venkatesh

James Chun
Kilo Patron

Hi @Bindhu1,

 

You can create an attachment type variable and use a UI Policy to display and mandate the attachment variable when the requested_for and site_owner variables are different.

e.g.

JamesChun_0-1715200462623.png

 

 

Cheers

swathisarang98
Giga Sage
Giga Sage

Hi @Bindhu1 ,

 

You can create a onchange client script and validate whether the requested for and site owner both are same them make attachment mandatory and visible,

swathisarang98_0-1715202634575.png

 

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading || newValue == '') {
	g_form.setDisplay('attachment',false);//upload button backend name
      return;
   }

   var requestedFor = g_form.getValue('requested_for');//Requested for backend name

   if(requestedFor != newValue){ //chceking onchange of site owner which is nothing but newValue
	g_form.setDisplay('attachment',true);
	g_form.setMandatory('attachment',true);
   }
   else{
	g_form.setMandatory('attachment',false);//upload button backend name
	g_form.setDisplay('attachment',false);
	
   }
   
}

 

 

Please mark this comment as Correct Answer/Helpful if it helped you.

Regards,

Swathi Sarang

Hi @swathisarang98 , thanks for your reply!
Here is a small correction , the 'requested for' is on request table , and 'site owner' is a cat item variable. How to we check in this case, could you please help me here ?