Closed pta-nmu closed 4 years ago
Hello Nick,
I had a quick look and one general thing before I talk about the issue. You make some require
statements in the beginning. In general it is advanteous to use import {XYZ} from 'myLib
because the ES6 import statements are executed async and in parallel in contrast to the blocking require which actually reads in a full file. SOmetimes they are needed but for importing libs like the SDK I would use import.
The error says:
TypeError: Cannot read property 'builder' of undefined
so the object is not there. The only access of builder() is IndividualCustomer.builder()
which is initialized via:
const { IndividualCustomer } = require('@sap/cloud-sdk-vdm-business-partner-service');
. And here lies the error I guess.
IndividualCustomer
is a C4C object of the business partner. But the @sap/cloud-sdk-vdm-business-partner-service
is the S/4HANA business partner. I checked and this object does not contain an IndividualCustomer
entity so that is why you get the undefined error.
Since you want to use serverless I am not sure if it is possible to upload some generated client for the C4C business partner since we do not ship these via npm at the moment.
Best Frank
Hi Frank, Thanks for the update. I replaced IndividualCustomer with BusinessPartner and now we're getting this error
Function failed to execute: TypeError: BusinessPartner.builder is not a function
Do you know what's wrong here?
Thanks Nick
Hi @pta-nmu,
Can you please post both the code and the complete error message?
Here is a part working code for creation:
const { IndividualCustomer } = require('kyma-c4-odata/IndividualCustomer');
const builder = IndividualCustomer.builder();
const IndividualCustomerCollection = IndividualCustomer.requestBuilder();
const jsonBody = {
"roleCode": "CRM000",
// other properties...
};
const individualCustomer = builder.fromJson(jsonBody);
const query = IndividualCustomerCollection
.create(individualCustomer);
let result;
try {
result = await query.execute(backend);
return result;
} catch(e) {
return {error: e};
}
Hey @pta-nmu can you also post the error message?
Hey @pta-nmu do you still encounter this issue? If yes, please share the complete (and current) error message, so that we can help you better.
Hi, @pta-nmu , @schamane,
To make it actionable we need the latest error message or stack trace. As it's not reproducible on our side there's no other way to investigate.
Hi guys, Next week we're moving to a new tenant so I'll park this. Thanks for your help.
Hi,
We are getting a TypeError when we attempt to create an IndividualCustomer using the CloudSDK. We're using a lambda function on our Kyma instance which has an environment variable to point to the C4C instance (via SAP cloud gateway, i.e. authentication is set up in the proxy). If we create directly in the OData Test console in our C4C frontend it works fine. Doing a POST to the C4C URL directly from Postman works if you use a pre-script to do a GET and grab the csrf token.
Have posted the lambda function code and a log snippet. Thanks for your help on this.
IND_log_2020-10-15.txt IND_create-indiv-customer-sdk.txt