Expand my Community achievements bar.

SOLVED

About Write & Update record of my own table create by my own schema

Avatar

Level 3

Hi :

I create a new schema (named product) in Adobe Campaign. And updated the database.

Now I want to write & update & delete the record in the product database. 

I can't find the API how to do that. 

Would you like teach me where is the guide of the method or tell me how to do that.

 

Best regards.

1 Accepted Solution

Avatar

Correct answer by
Employee

Hi,

Please refer to official documentation on how to read from and write to a schema.

Check for queryDef and Write APIs

You can also create your custom APIs.

Link: https://docs.campaign.adobe.com/doc/AC6.1/en/CFG_API_Data_oriented_APIs.html

Regards,

Vipul

View solution in original post

6 Replies

Avatar

Correct answer by
Employee

Hi,

Please refer to official documentation on how to read from and write to a schema.

Check for queryDef and Write APIs

You can also create your custom APIs.

Link: https://docs.campaign.adobe.com/doc/AC6.1/en/CFG_API_Data_oriented_APIs.html

Regards,

Vipul

Avatar

Level 3

Hi Vipul:

Thank you very much for your quick reply.

I read the guide. And have the next detail questions.

(1) should I define the method under my own prodct schema?

<method name="Write" static="true"> <parameters> <param name="doc" type="DOMDocument" desc="Difference document"/> </parameters> </method> <method name="WriteCollection" static="true"> <parameters> <param name="doc" type="DOMDocument" desc="Difference collection document"/> </parameters> </method>

(2) I read the example of Updating or inserting a recipient . as the follow.  

<recipient xtkschema="nms:recipient" email="john.doe@adobe.com" birthDate="1956/05/04" folder-id=1203 _key="@email, [@folder-id]"> <location city="Newton"/> </recipient>

What is the  TAG (<recipient />) to update record of my own schema? for example my own schema is my_namespace:my_schema_name.

(3) Did I need to implement my own "Write" method by JavaScript in my own schema to read and write record?  

Best regard.

Avatar

Level 1
In case anyone eplse face the same problem, the tag should always be your schema name without a namespace. For example, if your schema is temp:query1, then your xml should be <query1 xtkschema="temp:query1" ... />

Avatar

Employee

Hi,

Please find your answers here:

(1) The Write method is already present as part of xtk:session schema and you can leverage that. All it needs is the XML representation of an entity for your product schema.

(2) This is an example here to show you how to update a recipient in the recipient schema. You can tweak the example to use with your product schema accordingly.

(3) Not needed. Please use the one already exposed. 

Avatar

Level 3

Hi Vipul:

Thank you.

(2) What determines my own TAG name in the XML as the tag name <recipient /> if my schema is "bfwechat:wechatAccounts"

     I used  "wechatAccounts", but it is error when run the JavaScript Code.

<recipient xtkschema="nms:recipient" email="john.doe@adobe.com" birthDate="1956/05/04" folder-id=1203 _key="@email, [@folder-id]"> <location city="Newton"/></recipient>

 

My schema:

<srcSchema _cs="WechatAccounts (bfwechat)" created="2017-04-24 06:17:19.323Z" createdBy-id="0"
           desc="Accounts of Wechat" entitySchema="xtk:srcSchema" img="gzx:weicdhat.png"
           label="WechatAccounts" labelSingular="WechatAccount" lastModified="2017-05-04 05:36:02.849Z"
           mappingType="sql" md5="4BE35B360DF0DCC5F28E7A53C2D04E11" modifiedBy-id="0"
           name="wechatAccounts" namespace="bfwechat" xtkschema="xtk:srcSchema">
  <createdBy _cs="lizhigang (zhigang.li@bluefocus.com)"/>
  <modifiedBy _cs="lizhigang (zhigang.li@bluefocus.com)"/>

  <enumeration basetype="string" name="wechatAccountType">
    <value label="Subscription" name="subscription"/>
    <value label="Service" name="service"/>
  </enumeration>

  <element desc="Accounts of Wechat" img="gzx:weicdhat.png" label="WechatAccounts"
           labelSingular="WechatAccount" name="wechatAccounts">
    <key internal="true" name="accountId">
      <keyfield xpath="@accountId"/>
    </key>

    <attribute label="Id" name="accountId" type="string"/>
    <attribute enum="wechatAccountType" label="Type" name="accountType" type="string"/>
    <attribute label="Name" name="accountName" type="string"/>

    <compute-string expr="@accountType + ' ' + @accountName"/>
  </element>

</srcSchema>

My Java Script Code:

    var myXML = <wechatAccounts xtkschema="bfwechat:wechatAccounts" accountId="123456" _key="@accountId" />                
    xtk.session.Write(myXML)

Avatar

Level 3

Hi Vipul:

I use the  the root TAG as schema name (In my case “<wechatAccounts />”). It is ok now. 

There was a typo in the original writing. Sorry to bother you.

Thank you very much.

Best regards.