Forum Discussion

CharleneDougal1's avatar
Qrew Member
11 months ago

How to check if record field is empty in API_DoQuery

When I execute API_DoQuery in the Code Page I get the following XML results, when detail_note is empty.
However,  $(this).find("detail_note").text() returns 8 159 True 1689364909773 which are the values of the fields below.   Does anyone have a suggestion on how check if a field is empty?
<errtext>No error</errtext>
<name>PDA Supporting Documents</name>
<variables> </variables>
<chdbids> </chdbids>

Charlene Dougall

2 Replies

  • This may not answer your question specifically but I would make an attempt to avoid trying to parse the XML response directly and instead do 1 of 2 things: 

    Option 1: Use the REST API instead to query which would return the JSON response for each value and be much easier to parse. So instead of <detail_note/>, you would get a JSON response in the REST api more like "10": {value: ""} where 10 is the sample fid I'm using and you can check if "10"["value"] == "" 

    Option 2: Use an XML to JSON library that converts the XML response into digestable json format that you can evaluate more easily. Depending on the library the response might be different, but you either might not get a key/value pair at all if there is no detail or it might give you a blank value, either way its a much easier test. 

    Chayce Duncan
    • CharleneDougal1's avatar
      Qrew Member

      Thank you, Chayce. I will try that.

      Charlene Dougall