Universal Display File Issue

Use this board to ask questions or have discussions with other Rich Displays users.
Post Reply
mwalter
Experienced User
Posts: 140
Joined: Wed Sep 14, 2016 2:58 pm
First Name: Mark
Last Name: Walter
Company Name: Paragon Consulting Services
Contact:

Universal Display File Issue

Post by mwalter »

I know I'm missing something simple, but can't seem to locate it.

I have a universal display file that basically just returns the item description from the item number and location passed.

The UDF works fine in SOAPUI.

I'm basically getting the error that result is null. The actual error is "Cannot read property 'success' of null'.
Here is the javascript that I'm using to invoke the UDF.

Code: Select all

debugger;
ajaxJSON({
url: "/profoundui/universal/facValidItem",
params: {
itemNumber: getObj("txtItemNumber").value,
location: "01"
},
method: "get",
async: true,
handler: function(result) {
  if (result.success) {
    changeElementValue("txtDescription",result.itemDesc);
  }
  else {
    applyProperty("txtItemNumber","focus",true);
    getObj("txtItemNumber").select();
    alert(result.errorDesc);
  }  
}
});
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: Universal Display File Issue

Post by Scott Klement »

Mark,

Its not clear why result is coming back null for you. I would suggest using the browser's debugging tools to see what's going on.

I'd start with the "Network" tool to see that the HTTP request is running properly, and that it's returning the proper document.
mwalter
Experienced User
Posts: 140
Joined: Wed Sep 14, 2016 2:58 pm
First Name: Mark
Last Name: Walter
Company Name: Paragon Consulting Services
Contact:

Re: Universal Display File Issue

Post by mwalter »

Status is 200.
mwalter
Experienced User
Posts: 140
Joined: Wed Sep 14, 2016 2:58 pm
First Name: Mark
Last Name: Walter
Company Name: Paragon Consulting Services
Contact:

Re: Universal Display File Issue

Post by mwalter »

Ok, I think the problem may be the actual ajax call. I tried to put my RPG for the UDF into debug and it was never invoked. I can see the javascript fire in the Chrome debugger. I'm sure my PUIMAPP file is populated properly. I can even put the url/queryString into a browser and get the proper results. Not sure where to go from here.
mwalter
Experienced User
Posts: 140
Joined: Wed Sep 14, 2016 2:58 pm
First Name: Mark
Last Name: Walter
Company Name: Paragon Consulting Services
Contact:

Re: Universal Display File Issue

Post by mwalter »

I was wrong. The program is getting invoked because I sent it some bad data, and it abended. So, I'm back to square one. Why is my response null?

I can see the response in the response section of the Chrome network tool in the Developer Tools.
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: Universal Display File Issue

Post by Scott Klement »

ajaxJSON will pass null to your handler if the data isn't valid JSON data.

Here's an excerpt from the code inside the ajaxJSON routine:

Code: Select all

    var responseText = ajaxRequest.getResponseText();
    try {
      responseObj = eval("(" + responseText + ")");
    }
    catch(e) {
      callback(null, e);
      return;
    }
    if (async == true) {
      callback(responseObj);
    }
As you can see, it evaluates the JSON data into a JavaScript object in a try/catch group. The only time it calls your handler routine ("callback") and passes null is if the evaluation resulted in an error.
mwalter
Experienced User
Posts: 140
Joined: Wed Sep 14, 2016 2:58 pm
First Name: Mark
Last Name: Walter
Company Name: Paragon Consulting Services
Contact:

Re: Universal Display File Issue

Post by mwalter »

Thanks so much, AGAIN, Scott. I wasn't delimiting my character fields.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests