Skip to Content

update where Sdk Javascript

Hello,

I just would like to know, How I can convert this cap node js expression (update where) into SDK Javascript?

 await tx.run(UPDATE(testEntity).set({
                        city: dataCity,
                        country: dataCountry
                    }).where({
                        id: id,
                        postcode: dataPostcode
                    }))

Thank you very much

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Posted on 2 days ago

    Hi,

    We explain it in details in our documentation about update requests.

    It would be something like:

    BusinessPartner.requestBuilder().update(businessPartner);
    
    Add a comment
    10|10000 characters needed characters exceeded

    • Hi Artem

      Thank you very much for reply, I tried but I received the error: Error: value.utc is not a function

      const sdkTest = require('./odata-client/api-service-3').Test;
      
      sdkTest.city = dataCity
      sdkTest.country= dataCountry;
      sdkTest.id = dataID;
      sdkTest.postcode= dataPostcode;
      try{
      sdkTest.requestBuilder().update(sdkTest).execute({
        destinationName: 'DEST'
      });
      }catch(error){
         console.log('Error:', err.message);
      
      }

      Any help.

      Best

  • Posted on 19 hours ago

    Hi Artem Kovalov

    I can not able to update when my entity has 2 primary keys. I got error 417 and the log report that the url is not completed.

    PATCH api/Test(id='20200529' HTTP/1.1" 400 64 58

     const sdTest = sdkTests.builder()
                        .city(dataCity)
                        .country(dataCountry) // PrimaryKey
                        .id(dataID)  // PrimaryKey
                        .postcode(dataPostcode)
                        .build();
      const responseOne = sdkTests.requestBuilder().update(sdTest)
                        .setCustomServicePath('api/')
                        .execute({ destinationName: 'DEST' })
                        .catch(err => {
                            console.log('Error One:', err.message);
                            console.log('Cause:', err.rootCause.message);
                            console.log('Root cause:', err.rootCause.message);
                        });
    
    

    Any help

    Best

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.