try this if it works: /** * @NApiVersion 2.0 * @NScriptType Restlet */ define(['N/record', 'N/error'], function (record, error) { function createCustomRecord(context){ log.debug('context', context); var requestBody = context; // Define your custom record type internal ID var customRecordType = 'customrecord_your_custorec_id'; // Create a new record var customRecord = record.create({ type: customRecordType, isDynamic: true }); // Set field values from the request body for(var field in requestBody){ if(requestBody.hasOwnProperty(field)){ customRecord.setValue({ fieldId: field, value: requestBody[field] }); } } try{ // Save the record var recordId = customRecord.save(); return { success: true, recordId: recordId }; }catch(e){ // Handle errors log.error('Error creating custom record', e); throw error.create({ name: 'CREATION_ERROR', message: 'Error creating custom record' }); } } return{ post: createCustomRecord }; });
try this if it works: /** * @NApiVersion 2.0 * @NScriptType Restlet */ define(['N/record', 'N/error'], function (record, error) { function createCustomRecord(context){ log.debug('context', context); var requestBody = context; // Define your custom record type internal ID var customRecordType = 'customrecord_your_custorec_id'; // Create a new record var customRecord = record.create({ type: customRecordType, isDynamic: true }); // Set field values from the request body for(var field in requestBody){ if(requestBody.hasOwnProperty(field)){ customRecord.setValue({ fieldId: field, value: requestBody[field] }); } } try{ // Save the record var recordId = customRecord.save(); return { success: true, recordId: recordId }; }catch(e){ // Handle errors log.error('Error creating custom record', e); throw error.create({ name: 'CREATION_ERROR', message: 'Error creating custom record' }); } } return{ post: createCustomRecord }; });
try this if it works: /** * @NApiVersion 2.0 * @NScriptType Restlet */ define(['N/record', 'N/error'], function (record, error) { function createCustomRecord(context){ log.debug('context', context); var requestBody = context; // Define your custom record type internal ID var customRecordType = 'customrecord_your_custorec_id'; // Create a new record var customRecord = record.create({ type: customRecordType, isDynamic: true }); // Set field values from the request body for(var field in requestBody){ if(requestBody.hasOwnProperty(field)){ customRecord.setValue({ fieldId: field, value: requestBody[field] }); } } try{ // Save the record var recordId = customRecord.save(); return { success: true, recordId: recordId }; }catch(e){ // Handle errors log.error('Error creating custom record', e); throw error.create({ name: 'CREATION_ERROR', message: 'Error creating custom record' }); } } return{ post: createCustomRecord }; });
Thanks for the information.
how I can by pass first step authorization manually using UI login. or how I can increase expiry time of token?
Thanks for watching! and Thank you for your comment. we'll f/w your query to our technical team
Hi Amit, can you please share your restlet code?
try this if it works:
/**
* @NApiVersion 2.0
* @NScriptType Restlet
*/
define(['N/record', 'N/error'], function (record, error) {
function createCustomRecord(context){
log.debug('context', context);
var requestBody = context;
// Define your custom record type internal ID
var customRecordType = 'customrecord_your_custorec_id';
// Create a new record
var customRecord = record.create({
type: customRecordType,
isDynamic: true
});
// Set field values from the request body
for(var field in requestBody){
if(requestBody.hasOwnProperty(field)){
customRecord.setValue({ fieldId: field, value: requestBody[field] });
}
}
try{
// Save the record
var recordId = customRecord.save();
return { success: true, recordId: recordId };
}catch(e){
// Handle errors
log.error('Error creating custom record', e);
throw error.create({ name: 'CREATION_ERROR', message: 'Error creating custom record' });
}
}
return{
post: createCustomRecord
};
});
Hi Amit ji, I have a restlet code and I want to pass first name and last name in this. Could you please help me?
its only works one or two days after that logs showing invalid login attempt
Hey mate, for the love of Maradona. Could you share that script? - I'm very lost with this stuff
Hi can you please share your code for this restlet ?
Sure, please it will be sent to you, please share your email.
@@bispsolutions Can you share the restlet data with me, as well?
Thanks for the tutorial sir very helpful. Are you using SuiteScript 1.0?
Did you get the code? Can you please share it with me?
Can you also share it with me? Maybe make a video about it, seems a lot of people are interested.
You supposed to be show the restlet code,this is not useful
try this if it works:
/**
* @NApiVersion 2.0
* @NScriptType Restlet
*/
define(['N/record', 'N/error'], function (record, error) {
function createCustomRecord(context){
log.debug('context', context);
var requestBody = context;
// Define your custom record type internal ID
var customRecordType = 'customrecord_your_custorec_id';
// Create a new record
var customRecord = record.create({
type: customRecordType,
isDynamic: true
});
// Set field values from the request body
for(var field in requestBody){
if(requestBody.hasOwnProperty(field)){
customRecord.setValue({ fieldId: field, value: requestBody[field] });
}
}
try{
// Save the record
var recordId = customRecord.save();
return { success: true, recordId: recordId };
}catch(e){
// Handle errors
log.error('Error creating custom record', e);
throw error.create({ name: 'CREATION_ERROR', message: 'Error creating custom record' });
}
}
return{
post: createCustomRecord
};
});
not useful explain the code
Hi Amit, could you share your restlet code? please 🙏
Did you receive it?
try this if it works:
/**
* @NApiVersion 2.0
* @NScriptType Restlet
*/
define(['N/record', 'N/error'], function (record, error) {
function createCustomRecord(context){
log.debug('context', context);
var requestBody = context;
// Define your custom record type internal ID
var customRecordType = 'customrecord_your_custorec_id';
// Create a new record
var customRecord = record.create({
type: customRecordType,
isDynamic: true
});
// Set field values from the request body
for(var field in requestBody){
if(requestBody.hasOwnProperty(field)){
customRecord.setValue({ fieldId: field, value: requestBody[field] });
}
}
try{
// Save the record
var recordId = customRecord.save();
return { success: true, recordId: recordId };
}catch(e){
// Handle errors
log.error('Error creating custom record', e);
throw error.create({ name: 'CREATION_ERROR', message: 'Error creating custom record' });
}
}
return{
post: createCustomRecord
};
});