Jump to content

Custom field showing in UI but not in API


 Share

Recommended Posts

We have a custom field added to our Sales Orders (SODOCUMENT) called PLOT as a Text type. This showing and we're able to add data through the UI. However when read this object VIA the API, this field is not being returned.

I as using the Sage PHP SDK, and basic code:

 

$where1 = new EqualToString();
$where1->setField('DOCNO');
$where1->setValue($doc_id);
$query1 = new ReadByQuery();
$query1->setObjectName("SODOCUMENT");
$query1->setQuery($where1);

Am I missing something?

Link to comment
Share on other sites

  • Members

The SODOCUMENT object represents all header-level Order Entry transaction types. Each transaction type, such as "Sales Order" or "Sales Invoice," can have its own custom fields. To specify which type of Order Entry transaction you're querying, use the docparid field.

For example:

<content>
  <function controlid="testControlId">
    <readByQuery>
      <object>SODOCUMENT</object>
      <fields>*</fields>
      <query></query>
      <returnFormat>xml</returnFormat>
      <pagesize>100</pagesize>
      <docparid>Sales Invoice</docparid>
    </readByQuery>
  </function>
</content>
 

This query will return the custom fields specific to the "Sales Invoice" transaction type.

If the SDK doesn't support this out-of-the-box, you may need to extend the SDK to handle it, as it ultimately generates XML requests like the one above.

Link to comment
Share on other sites

  • 2 weeks later...

I appreciate the support... all working now. I had to get the case correct otherwise nothing returns... 

I'm amending my solution for the next person 🙂

 

$where1 = new EqualToString();
$where1->setField('DOCNO');
$where1->setValue($doc_id);
$query1 = new ReadByQuery();
$query1->setObjectName("SODOCUMENT");
$query1->setDocParId("Sales order");
$query1->setQuery($where1);

I'm guessing this ties back to object inheritance?

Link to comment
Share on other sites

 Share

×
×
  • Create New...