Home General Discussion

Cireson Portal

CaterhamITSupportCaterhamITSupport Member Advanced IT Monkey ✭✭✭

Dear All,

I would like to hide support group on the incident form when a pull down equals a value.

Is this possible?

Kind Regards

Daniel

Best Answer

  • Simon_ZeinhoferSimon_Zeinhofer Customer Ninja IT Monkey ✭✭✭✭
    Answer ✓

    @CaterhamITSupport

    i have found a solution which should work 1:1 for you.

    All you have to do is changing the ID of the line

    if (viewModel.Classification.Id == '580f8b0b-e8af-2ea5-fb69-1c58e4d24788')
    

    to the id you have gotten through the console. The .parent() hides the complete support group label.

    app.custom.formTasks.add('Incident', null, function (formObj, viewModel) {
               
       //Incident OnReady
       formObj.boundReady(function () {
        
            //Code here will run when the Incident form has loaded.
            
            //Get the AutoClose label
            var autoCloseLabel = $(".form-group label[for='TierQueue']");
    		
    		
    		if (viewModel.Classification.Id == '580f8b0b-e8af-2ea5-fb69-1c58e4d24788'){
    			autoCloseLabel.parent().hide();
    		}
    		else{
    		
            autoCloseLabel.parent().show();
    		
    		}
    
    
            return;
    	});
    	
    	
    	 //Incident Classification changed
        formObj.boundChange("Classification", function () {
        //Code here will run every time the Classification category picker is changed.
        
            //Get the Network Description label
            var autoCloseLabel = $(".form-group label[for='TierQueue']")
    
    
            
            //If Classification 'Reset Password / SAP' is selected
            if (viewModel.Classification.Id == '580f8b0b-e8af-2ea5-fb69-1c58e4d24788')
            {
                //Show Auto Close label and field
                autoCloseLabel.parent().hide();
            
                //Set Auto Close Label red
                
    
    
    
    
                
            }else{
                //Reset back to default if another category is selected
               
    				
                    autoCloseLabel.parent().show();
                
            }
            });
            return;
    
    
    });
    

    For me it works the way you want it

Answers

  • Simon_ZeinhoferSimon_Zeinhofer Customer Ninja IT Monkey ✭✭✭✭
    edited February 2023

    We do the same with an Auto Resolve Checkbox for certain incident classifications.

    You can edit the script for your needs.

    Ofc don't forget to add it to the custom.js

    app.custom.formTasks.add('Incident', null, function (formObj, viewModel) {
               
       //Incident OnReady
       formObj.boundReady(function () {
        
            //Code here will run when the Incident form has loaded.
            
            //Get your label you want to hide
            var yourLABEL = $(".form-group label[for='YOUR LABEL NAME']");
    		
                    //we go for the classification here, if you need something else
                    // you need to find the name and value inside the pageForm.viewModel
    		if (viewModel.Classification.Id == 'd4b400c0-8dc8-4d84-dcf0-05c8751f8a48'){
    			yourLABEL.hide();
    			
    		}
    		else{
    		
            autoCloseLabel.show();
    		
    		}
    
    
            return;
    	});
    	
    	
    	 //Incident Classification changed
        formObj.boundChange("Classification", function () {
        //Code here will run every time the Classification category picker is changed.
        
            //Get the label
            var yourLABEL = $(".form-group label[for='YOUR LABEL NAME']")
    
    
            
            //If Classification is selected
            if (viewModel.Classification.Id == 'd4b400c0-8dc8-4d84-dcf0-05c8751f8a48')
            {
    
                yourLABEL.hide();
     
            }else{
    		
                    yourLABEL.show();
                
            }
            });
            return;
    
    
    });
    
  • CaterhamITSupportCaterhamITSupport Member Advanced IT Monkey ✭✭✭
    edited February 2023

    Is there anyway to simify this?

    I just need it to hide the support group tierqueue when classification == a value?

    I don't understand the coding here.

  • Simon_ZeinhoferSimon_Zeinhofer Customer Ninja IT Monkey ✭✭✭✭

    @CaterhamITSupport

    The thing is, you need both functions:

    The first is for the situation where the classification, which triggers the hiding, is set when you open the incident.

    The second is for the situation where you change the classification to the one which triggers the hiding.

    I am not rly good with javascript so I cannot tell you if you can simplify it, but maybe someone else knows that ;)

  • CaterhamITSupportCaterhamITSupport Member Advanced IT Monkey ✭✭✭

    I tried this code and it didnt work for me, thank you though.

  • Simon_ZeinhoferSimon_Zeinhofer Customer Ninja IT Monkey ✭✭✭✭
    edited February 2023

    @CaterhamITSupport Have you just copied it 1 to 1?


    1. You have to change the id from this line (inside both functions) to the enumeration guid of your classification:
    if (viewModel.Classification.Id == 'd4b400c0-8dc8-4d84-dcf0-05c8751f8a48')
    

    2. Have you changed the label in this to the following in both functions?

     var yourLABEL = $(".form-group label[for='TierQueue']");
    

    3. Have you saved this .js file with the code inside your customspace folder and imported it into your custom.js file? :)

    Without that nothing will happen ;-)

  • CaterhamITSupportCaterhamITSupport Member Advanced IT Monkey ✭✭✭

    I am trying to find the classification ID in number 1. How is best to get this unique ID? I have tried to find it in SQL on the DWH but it doesnt work with this value and crashes the incident form.

  • Simon_ZeinhoferSimon_Zeinhofer Customer Ninja IT Monkey ✭✭✭✭

    @CaterhamITSupport

    there are some ways to accomplish that.

    You could just go into an incident and choose the classification, which woud trigger the hiding of the support group label. Then press F12 on your keyboard, so the console opens.

    Inside the terminal just write: pageForm.viewModel.Classification.Id

    The following should appear:


    This is the ID(GUID) of your classification, which you have to insert into the block i pasted before.

  • CaterhamITSupportCaterhamITSupport Member Advanced IT Monkey ✭✭✭
    edited February 2023

    Are you referring to doing this in the console or portal?

  • Simon_ZeinhoferSimon_Zeinhofer Customer Ninja IT Monkey ✭✭✭✭

    @CaterhamITSupport Everything in the portal.

    F12 opens the Browser console, not the SCSM Console ;-) Sry if that was confusing

  • CaterhamITSupportCaterhamITSupport Member Advanced IT Monkey ✭✭✭

    Is this using Edge or Chrome?

  • Simon_ZeinhoferSimon_Zeinhofer Customer Ninja IT Monkey ✭✭✭✭

    Works in every browser. I would recommend using Edge for that

  • CaterhamITSupportCaterhamITSupport Member Advanced IT Monkey ✭✭✭

    I think with your direction I may have just worked it out.

  • CaterhamITSupportCaterhamITSupport Member Advanced IT Monkey ✭✭✭

    This does sort of work. I need it to hide the text box and label. It also doesnt work if other classifications are selected. A step in the right direction thank you.

  • Simon_ZeinhoferSimon_Zeinhofer Customer Ninja IT Monkey ✭✭✭✭
    Answer ✓

    @CaterhamITSupport

    i have found a solution which should work 1:1 for you.

    All you have to do is changing the ID of the line

    if (viewModel.Classification.Id == '580f8b0b-e8af-2ea5-fb69-1c58e4d24788')
    

    to the id you have gotten through the console. The .parent() hides the complete support group label.

    app.custom.formTasks.add('Incident', null, function (formObj, viewModel) {
               
       //Incident OnReady
       formObj.boundReady(function () {
        
            //Code here will run when the Incident form has loaded.
            
            //Get the AutoClose label
            var autoCloseLabel = $(".form-group label[for='TierQueue']");
    		
    		
    		if (viewModel.Classification.Id == '580f8b0b-e8af-2ea5-fb69-1c58e4d24788'){
    			autoCloseLabel.parent().hide();
    		}
    		else{
    		
            autoCloseLabel.parent().show();
    		
    		}
    
    
            return;
    	});
    	
    	
    	 //Incident Classification changed
        formObj.boundChange("Classification", function () {
        //Code here will run every time the Classification category picker is changed.
        
            //Get the Network Description label
            var autoCloseLabel = $(".form-group label[for='TierQueue']")
    
    
            
            //If Classification 'Reset Password / SAP' is selected
            if (viewModel.Classification.Id == '580f8b0b-e8af-2ea5-fb69-1c58e4d24788')
            {
                //Show Auto Close label and field
                autoCloseLabel.parent().hide();
            
                //Set Auto Close Label red
                
    
    
    
    
                
            }else{
                //Reset back to default if another category is selected
               
    				
                    autoCloseLabel.parent().show();
                
            }
            });
            return;
    
    
    });
    

    For me it works the way you want it

  • CaterhamITSupportCaterhamITSupport Member Advanced IT Monkey ✭✭✭

    This works!

    Really appreciated the help with this.

    Kind Regards

    Daniel

  • CaterhamITSupportCaterhamITSupport Member Advanced IT Monkey ✭✭✭

    How would i change it from hiding a enum to a user picker?

  • Simon_ZeinhoferSimon_Zeinhofer Customer Ninja IT Monkey ✭✭✭✭

    Now that you have gotten a full working solution, I'd say you just try it yourself. That's the best way to implement such things by yourself.

  • CaterhamITSupportCaterhamITSupport Member Advanced IT Monkey ✭✭✭

    Ok thanks for the help, the code is causing some minor issues with required fields on the page now. I will take a closer look into this.

Sign In or Register to comment.