9 Replies · Latest reply on Jun 19, 2017 3:40 PM by r0b0_d3vil

    Optimization Problem

      I have some before-query-business rules  (one for the Task table, Incident, Problem, and one for Change) whose order is different from each other. I don't know why when I try to use Service Portal, It takes around a minute before loading the page.

      How can I fix the problem?

      Thanks

        • Re: Optimization Problem
          r0b0_d3vil

          Hi Andrea

           

          Are you sure this is the cause of your issue ?

          Did you try to deactivate all the BRs and check if the business rules are impacting on the portal ?

           

          Cheers

          R0b0

            • Re: Optimization Problem
              Andrea Zaffaroni

              Well actually, I can say that the problem is caused by the BR on the Task table...I still do not know the reason! Maybe it is due to the fact that inside this BR I made a script in order to restrict the visibility of problems changes and so on depending on the user's roles. Since I need to recover for instance all the incidents submitted in which the callers have some properties, the script  recalls some functions defined in a script include. I made this kind of operation three times in this BR.

                • Re: Optimization Problem
                  r0b0_d3vil

                  Hi Andrea

                   

                  What do you mean 3 times ?

                  Did you try to move the business rule on the specific table instead doing something against the task table ?

                   

                  Cheers

                  R0b0

                    • Re: Optimization Problem
                      Andrea Zaffaroni

                      Thie following is a function defined in the script Include tha I recalled in this BR:

                       

                      returnInc:function(){

                        var y3 = this.returnHub();

                        var incNumber1 = [];

                        var b=0;

                        var k;

                        var inc4 = new GlideRecord('incident');

                        inc4.query();

                        while(inc4.next()){

                        for(k=0;k<y3.length;k++){

                        if(inc4.caller_id.company.u_hub==y3[k]){

                        incNumber1[b]=inc4.getValue('number');

                        }

                        }

                        b++;

                        }

                        return incNumber1;

                      },

                       

                      As you can notice I didn't have the caller field on the task table, that's why I think I'm obliged to do something like this. This situation is repeated three times: one to recover some incidents, the second to recover some problems and the last for the change. Yeah surely maybe It's not the best solution but I have no different ideas in my mind, do you have any?

                        • Re: Optimization Problem
                          r0b0_d3vil

                          Hi Andrea

                           

                          Ok. From your code i can see that you have a list of u_hub.

                          You can simply try to create a list of these hubs comma separated.

                          Than change the query to something like this

                           

                          var inc4 = new GlideRecord('incident');

                          inc4.addQuery('caller_id.company.u_hub','IN','hub_a,hub_b,hub_c');

                          inc4.query();

                          while(inc4.next()){

                            incNumber1[b]=inc4.getValue('number');

                            b++;

                          }

                           

                          This will avoid that huge loop against all the incidents repeated against the array.

                           

                          Try and let me know

                          Cheers

                          R0b0

                        • Re: Optimization Problem
                          Andrea Zaffaroni

                          I have already defined the query business rules on the 'famous' specific tables, that are Incident, Problem, Change Request. What I would like to obtain as soon as any current user moves to My Work (which refers to the Task table) is the complete list of his incidents, problems and changes. That is the reason why I also made a BR on the Task table