Return Multiple Values from Script Include (JSON Object)

Поделиться
HTML-код
  • Опубликовано: 11 сен 2024

Комментарии • 19

  • @shaafiqandshoaibvlogs
    @shaafiqandshoaibvlogs 8 месяцев назад

    excellent .waiting for more use cases.

    • @techwithpri
      @techwithpri  8 месяцев назад

      New video is already uploaded go ahead and check it out 😁

  • @abhiramveeturi1956
    @abhiramveeturi1956 2 месяца назад

    In the output for the list incidents raised by caller all are seperated by comma(,). Can you please let me know is there a way to remove it (,)while printing the output?

    • @techwithpri
      @techwithpri  2 месяца назад

      Hey 👋
      Yes because it is an array type thats why it will return with comma 🤓

  • @Saiku_264
    @Saiku_264 26 дней назад

    Hii Pritam,
    I am getting like this at the top of client script "New client-scripts are run in strict mode, with direct DOM access disabled. Access to jQuery, prototype and the window object are likewise disabled. To disable this on a per-script basis, configure this form and add the "Isolate script" field. To disable this feature for all new globally-scoped client-side scripts set the system property "glide.script.block.client.globals" to false. " Will this affect the output?
    and also here is my code
    for script include:
    getINC: function(){
    var incArray=[];
    var gr=new GlideRecord("incident");
    gr.addQuery("caller_id",this.getParameter("sysparm_user_id"));
    gr.query();
    while(gr.next()){
    var incDetails={};
    incDetails.number=gr.number.toString();
    incDetails.priority=gr.priority.getDisplayValue();
    incDetails.short_desc=gr.short_description.toString();
    incArray.push(incDetails);
    }
    return JSON.stringify(incArray);
    },
    for client script
    var finalArray = [];
    var ga = new GlideAjax("demo");
    ga.getParam("sysparm_name", getINC);
    ga.getParam("sysparm_user_id", g_form.getValue("caller_id"));
    ga.getXMLAnswer(INCdetail);
    function INCdetail(response) {
    var obj = JSON.parse(response);
    for (var i = 0; i < obj.length; i++) {
    finalArray.push(obj[i].number + "
    " + obj[i].priority + "
    " + obj[i].short_desc + "

    " );
    }
    g_from.setValue("description",finalArray);
    }
    Please let me know if there is any error as I am not getting the result.

    • @Saiku_264
      @Saiku_264 26 дней назад

      I'm sorry I changed getParam to addParam but still I am not getting the output

    • @techwithpri
      @techwithpri  22 дня назад

      It seems all okay!!
      Try adding gs.log in script include and alert in client script to check where the value is missing !

  • @rohitdwivedi8195
    @rohitdwivedi8195 6 месяцев назад

    Please also give some info regarding debug for two ways in snow client and snow

    • @techwithpri
      @techwithpri  6 месяцев назад

      Hey !!
      Sure there would be videos on the same in my ServiceNow development series.
      Keep watching and keep learning 🤓

  • @PavanKumarReddy-lu3qx
    @PavanKumarReddy-lu3qx 2 месяца назад

    I'm getting same incidents for all the users, why it's happening like this?

    • @techwithpri
      @techwithpri  2 месяца назад

      Hey 👋
      There must be something wrong in the code itself, check twice.
      If that does not solve the problem..
      Send me the code here so that I can check from my end.

  • @chellamarudhupandianc3617
    @chellamarudhupandianc3617 9 месяцев назад

    im getting this error when changing the username "onChange script error: TypeError: Cannot read properties of undefined (reading 'apply') function () { [native code] }"
    My Script include is as follows :
    var getIncDetails = Class.create();
    getIncDetails.prototype = Object.extendsObject(AbstractAjaxProcessor, {
    getInc: function() {
    var incArray = [];
    var gr = new GlideRecord('incident');
    gr.addQuery('caller_id', this.getParameter('sysparm_user_id'));
    gr.query();
    while (gr.next()) {
    var incDetails = {};
    incDetails.number = gr.number.toString();
    incDetails.priority = gr.priority.getDisplayValue();
    incDetails.short_desc = gr.short_description.toString();
    incArray.push(incDetails);
    }
    return JSON.stringify(incArray);
    },
    type: 'getIncDetails'
    });
    My onChange client script is as follows :
    function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
    return;
    }
    var finalArray = [];
    var ga = GlideAjax('getIncDetails');
    ga.addParam('sysparm_name', 'getInc');
    ga.addParam('sysparm_user_id', g_form.getValue('caller_id'));
    ga.getXMLAnswer(IncDetail);
    function IncDetail(response){
    var obj = JSON.parse(response);
    for( i=o; i

    • @techwithpri
      @techwithpri  9 месяцев назад +1

      Hey!!
      Thanks for asking!!
      What I can see is in the On Change Client Script you did not mention the keyword 'new' while declaring the GlideAjax object.
      It should be
      var ga = New GlideAjax('getIncDetails');
      Let me know if you still getting the error.

    • @chellamarudhupandianc3617
      @chellamarudhupandianc3617 9 месяцев назад +1

      thank you 🤩@@techwithpri . just to let you know your virtual agent class was brilliant . my team mates were impressed .

    • @techwithpri
      @techwithpri  9 месяцев назад +1

      @@chellamarudhupandianc3617 The pleasure is all mine !! 😃
      Ask them to share with more people so that It can reach out to many people.
      And here goes some good news, the part 2 of the Virtual Agent Series is coming very soon.
      Where we will deal with complex use cases and advance things.
      And there would be lot of things for the members.
      Keep watching and keep learning 😇!!

    • @user-lg7fs1dg7o
      @user-lg7fs1dg7o 8 месяцев назад

      @@chellamarudhupandianc3617I did the same mistake😃😃😃