Issue when using alert within a function

LabKey Trial Support
Issue when using alert within a function rita alves  2019-10-28 04:21
Status: Closed
 
Hello

I have the following questions within a survey design code:

{"name" : "inidt",
  caption" : "Data de início:",
  "xtype": "datefield"},

 {"extConfig":{
              "fieldLabel": "Descontinuação?",
              "xtype":"radiogroup",
             "name":"discquestion",
            "columns":1,
             "items":[
                {"boxLabel":"Sim",
                  "name":"disc",
                  "inputValue": 1},
                {"boxLabel":"Não",
                 "name":"disc",
                 "inputValue": 0},
                {"boxLabel":"Desconhecido",
                 "name":"disc",
                 "inputValue": "NA"}]}},

         {"extConfig":{
            "name" : "discdt",
            "fieldLabel" : "Data de descontinuação:",
            "xtype": "datefield",
            "hidden": true},
          "listeners": {
             "change": {
               "question": "discquestion",
                  "fn" : "function(me, cmp, newValue, oldValue){var cmp2 = cmp.getValue(); if (cmp2.disc == 1) {me.setVisible(newValue); console.log(cmp2.disc);} else {me.setVisible(false);}} "}}},

 {"extConfig":
                 {"name" : "obs",
                  "caption" : " ",
                  "xtype": "textareafield",
                 "grow" : true,
                 "width": 800,
                 "height": 200},
                "listeners": {
                     "change": {
                           "question": ["discdt","inidt"],
                          "fn" : "function(me, cmp, newValue, oldValue){var q1 = cmp.getName(); var q2 = cmp.getName(); if (q1 == 'inidt'){q1val = newValue; console.log(newValue);} else if (q2 == 'discdt'){q2val = newValue; console.log(newValue);}; if (q1val>=q2val){alert('nooooooo')};}; console.log(newValue); "}}}

I was trying to make question "discdt" visible only if disc = 1 (this is working). Although I would like to add a validation of the dates: discdt has to be more recent than inidt. This is working if i am creating a new survey. Howerver when I try to access a saved/submitted survey it is just "loading" (this is a problem cause I need to access the surveys after they are filled).

Could you please help?
Thank you!
 
 
Jon (LabKey DevOps) responded:  2019-10-30 16:40
Hello Rita,

The loading screen you're seeing though is likely due to the survey trying to pull data in from the table your survey is attached to, but is unable to retrieve it due to the Javascript code you're using within the survey while you're recalling it. Unfortunately, we are unable to troubleshoot or debug your javascript code per our Forum Guidelines (https://www.labkey.org/home/Support/wiki-page.view?name=communityForumGuidelines) That level of support is reserved for our Premium Edition subscribers of LabKey. If you are interested in pursuing our Premium Edition, please feel free to fill out our Contact Us form expressing your interest (https://www.labkey.com/about/contact/).

Regards,

Jon