Update data to DB

Hi,

I'm having problem with scripting for updating value to DB,
I have and object with below structure
Client(
          IdAccess,
PhoneNo,
Email,
Password
)

How to manipulate and object from query below for instance to update an email address to another value from "http!request.queryParameters.email"? I need this for saving it to DB! or any simple way to do only for updating field?
local!clientAccess: a!queryEntity(
entity: cons!ITR_CONS_Client,
query:
                              a!query(
                              logicalExpression:a!queryLogicalExpression(
                                        operator:"AND",
                                        filters:{
                                        a!queryFilter(
                                                  field: "PhoneNo",
                                                  operator: "=",
                                                  value:http!request.queryParameters.userId
                                        ),
                                        a!queryFilter(
                                                  field: "Password",
                                                  operator: "=",
                                                  value:http!request.queryParameters.oldPassword
                                        )
                                        }
                              ),
                              pagingInfo: a!pagingInfo(
                                        startIndex: 1,
                                        batchSize: 50
                              )
                              )
).data

OriginalPostID-269252

  Discussion posts and replies are publicly visible

Parents
  • Hi,

    Thanks for replying, I'm able update using below script:

    a!writeToDataStoreEntity(
    dataStoreEntity: cons!ITR_CONS_ClientAccess,
    valueToStore: {
    IdAccess:local!clientAccess.IdAccess,
    PhoneNo:local!clientAccess.PhoneNo,
    Email:http!request.queryParameters.Email,
    Password:local!clientAccess.newPassword
    }
    ,
    onSuccess: a!httpResponse(
    statusCode: 200,
    headers: {
    a!httpHeader(name: "Content-Type", value: "application/json")
    },
    body: a!toJson(
    {
    status : "success",
    message: ""
    }
    )
    ),
    onError: a!httpResponse(
    statusCode: 500,
    headers: {
    a!httpHeader(name: "Content-Type", value: "application/json")
    },
    body: a!toJson(
    {
    status : "error",
    message: "There was an error writing to the data store"
    }
    )
    )
    )

    Is there any simple way to update only certain column (Email column), no need to define all the column?
Reply
  • Hi,

    Thanks for replying, I'm able update using below script:

    a!writeToDataStoreEntity(
    dataStoreEntity: cons!ITR_CONS_ClientAccess,
    valueToStore: {
    IdAccess:local!clientAccess.IdAccess,
    PhoneNo:local!clientAccess.PhoneNo,
    Email:http!request.queryParameters.Email,
    Password:local!clientAccess.newPassword
    }
    ,
    onSuccess: a!httpResponse(
    statusCode: 200,
    headers: {
    a!httpHeader(name: "Content-Type", value: "application/json")
    },
    body: a!toJson(
    {
    status : "success",
    message: ""
    }
    )
    ),
    onError: a!httpResponse(
    statusCode: 500,
    headers: {
    a!httpHeader(name: "Content-Type", value: "application/json")
    },
    body: a!toJson(
    {
    status : "error",
    message: "There was an error writing to the data store"
    }
    )
    )
    )

    Is there any simple way to update only certain column (Email column), no need to define all the column?
Children
No Data