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

tumuzhuanjia

03-05-2017

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.

Accepted Solutions (1)

Accepted Solutions (1)

Answers (4)

Answers (4)

tumuzhuanjia

04-05-2017

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. 

tumuzhuanjia

03-05-2017

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)

Vapsy

Employee

03-05-2017

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. 

tumuzhuanjia

03-05-2017

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.