Forum Discussion

CharleneDougal1's avatar
CharleneDougal1
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 www.yahoo.com 1689364909773 which are the values of the fields below.   Does anyone have a suggestion on how check if a field is empty?
 
<qdbapi>
<action>API_DoQuery</action>
<errcode>0</errcode>
<errtext>No error</errtext>
<dbinfo>
<name>PDA Supporting Documents</name>
<desc/>
</dbinfo>
<variables> </variables>
<chdbids> </chdbids>
<record>
<detail_note/>
<support_document/>
<record_id_>8</record_id_>
<related_pda_support_document___pda_record_id>159</related_pda_support_document___pda_record_id>
<iscurrentuserrecordowner>True</iscurrentuserrecordowner>
<support_url>www.yahoo.com</support_url>
<update_id>1689364909773</update_id>
</record>
</qdbapi>


------------------------------
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
      CharleneDougal1
      Qrew Member

      Thank you, Chayce. I will try that.



      ------------------------------
      Charlene Dougall
      ------------------------------