How to check view name using client script?

dianemiro
Kilo Sage

Hi,

I am trying to make a client script with the condition View == self_service and if true I want to set the state to Active. Here's my code but it is not working. Do you have any other way to meet what I am trying to do?

function onLoad() {

    //Type appropriate comment here, and begin script below

    var view = getView();

  if (view == 'self_service'){

  g_form.setValue('state','2');

  }

}

1 ACCEPTED SOLUTION

BALAJI40
Mega Sage
  1. function onLoad() {  
  2.     //Type appropriate comment here, and begin script below  
  3.     var view = getView();  
  4.   if (view == 'ess'){   //self service view name is ess so make to ess
  5.   g_form.setValue('state','2');  
  6.   }  
  7. }  

try this script.


View solution in original post

11 REPLIES 11

BALAJI40
Mega Sage
  1. function onLoad() {  
  2.     //Type appropriate comment here, and begin script below  
  3.     var view = getView();  
  4.   if (view == 'ess'){   //self service view name is ess so make to ess
  5.   g_form.setValue('state','2');  
  6.   }  
  7. }  

try this script.


Hi Balaji,



Thank you so much for your quick response. I changed the name to 'ess' and got the feature that I want. Thanks again for your help.


Hi balaji ,

I do have similar kind of issue that in self service view if i submit a ticket ,in the default view the following field(category ,sub category,business services) should populate with the value " To be classified"and assignment group to be help desk.

But unfortunately the script that i wrote in Business rule (after insert)does not work.

May i know what went wrong in the script below:

 

(function executeRule(current, previous /*null when async*/) {
                if (getView() == 'ess'){
                current.category='to be classified';
                current.subcategory='To be classified';
                current.description=current.u_description;                  
                current.business_service=current.u_impactedservices;
            
              current.assignment_group='d083a34cdbfc04102db740a505961902';
            if(current.u_impactedservices==''){
                          
    current.business_service.setDisplayValue('To be classified');
            }    
    
            
current.update();
                }
})(current, previous);

 

Thanks in advance

Community Alums
Not applicable

Hey, I do have similar requirement like once form submitted from self-service view the 'contact_type' should be set to self-service on default view.

i created client script on-submit, and selected 'ess' view and done the following code, can you tell me what's wrong here, it's not setting the value

function onSubmit() {
var view = getView();

if (view == 'ess'){

g_form.setValue('contact_type', 'self-service');
}