cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X

How to update a row in an infotable?

yingziDing
12-Amethyst

How to update a row in an infotable?

Hi,

I use the method UpdateQuery to update a row in an infotable.

When I test the service, it worked. But the row in the infotable had not been changed. I checked the query result and the updateQuery result, and they worked. But the data in the infotable was not updated.

----------------------------------------------------------------------------------------------------

// MN_FamilyMemberData entry object

var newEntry = new Object();

newEntry.birthday = birthday;// DATETIME

newEntry.accountId = accountId;// STRING

newEntry.healthCondition = healthCondition;// STRING

newEntry.personalPhone = personalPhone;// STRING

newEntry.gender = gender;// STRING

newEntry.socialSecurityNumber = socialSecurityNumber;// STRING

newEntry.memberName = memberName;// STRING

newEntry.ID = ID;// STRING

newEntry.height = height;// NUMBER

newEntry.memberId = memberId;// STRING

var params = {

  infoTableName : "newInfotable",

  dataShapeName : "MN_FamilyMemberData"

};

// CreateInfoTableFromDataShape(infoTableName:STRING("InfoTable"), dataShapeName:STRING):INFOTABLE(MN_FamilyMemberData)

var newInfotable = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);

newInfotable.AddRow(newEntry);

var query = {

    "filters": {

        "type": "AND",

        "filters": [

            {

                "fieldName": "accountId",

                "type": "LIKE",

                "value": accountId

            }

            ,

            {

                "fieldName": "memberId",

                "type": "LIKE",

                "value": memberId

            }

        ]

    }

};

var params = {

    t: me.FamilyMemberList /* INFOTABLE */,

    query: query /* QUERY */,

    values: newInfotable /* INFOTABLE */

};

// result: INFOTABLE

Resources["InfoTableFunctions"].UpdateQuery(params);

var params = {

    Code: 0 /* NUMBER */

};

// result: INFOTABLE dataShape: ReturnValueDefinitionData

var result = Things["ReturnValueDefinition"].ReturnInfomation(params);

----------------------------------------------------------------------------------------------------------------------

6 REPLIES 6

Hi yz ding​,

As per my understanding; you are not saving the updated infotable:

Try changing

// result: INFOTABLE

Resources["InfoTableFunctions"].UpdateQuery(params);

to

// result: INFOTABLE

var result1 = Resources["InfoTableFunctions"].UpdateQuery(params);

newInfotable = result1; // Now newInfotable has the updated data

Thanks, I understand what you mean. I solve the problem.

Hi yz ding​,

I am glad it worked. Could you please mark Correct and helpful answers in the Thread to help other members know that this Thread has a Solution.

posipova
20-Turquoise
(To:yingziDing)

Please refer to this thread, you may find some useful information :

Update Single InfoTable Row with a Service

Thanks, it's helpful

var newEntry = new Object();

newEntry.accountId = accountId;

newEntry.memberId = memberId;

var modified = me.FamilyMemberList;

var row = modified.Find(newEntry);

if(row == null){

    var newRow = new Object();

    newRow.accountId = accountId;// STRING

    newRow.memberId = memberId;// STRING

    newRow.memberName = memberName;// STRING

    newRow.gender = gender;// STRING

    newRow.birthday = birthday;// DATETIME

    newRow.height = height;// NUMBER

    newRow.socialSecurityNumber = socialSecurityNumber;// STRING

    newRow.ID = ID;// STRING

    newRow.personalPhone = personalPhone;// STRING

    newRow.healthCondition = healthCondition;// STRING

   

    modified.AddRow(newRow);

    me.FamilyMemberList = modified;

}

else{

    row.memberName = memberName;

    row.height = height;

    row.gender = gender;

    row.healthCondition = healthCondition;

    row.personalPhone = personalPhone;

    row.socialSecurityNumber = socialSecurityNumber;

    row.birthday = birthday;

    row.ID = ID;

    row.accountId = accountId;

    row.memberId = memberId;

    me.FamilyMemberList = modified;

}

Announcements


Top Tags