user93865
11/18/2024, 4:05 PMCeligo AI
11/18/2024, 4:05 PMAI generated answer (using internal Slack threads):Based on the conversations, here are the code snippets you requested: 1. Storing credentials in a custom record using `Form.addCredentialField()`:
javascript
var serverWidget = require('N/serverWidget');
var record = require('N/record');
function beforeLoad(context) {
if (context.type !== context.UserEventType.CREATE)
return;
var form = context.form;
var credField = form.addCredentialField({
id: 'custpage_cred',
label: 'Credential',
restrictToScriptIds: ['customscript_my_script'],
restrictToCurrentUser: false
});
}
function afterSubmit(context) {
var newRecord = context.newRecord;
var credId = newRecord.getValue('custpage_cred');
var customRecord = record.create({
type: 'customrecord_my_custom_record'
});
customRecord.setValue('custrecord_cred_id', credId);
customRecord.save();
}
2. Using the stored credential with `https.createSecureString()`:
javascript
var https = require('N/https');
var record = require('N/record');
function execute() {
var customRecord = record.load({
type: 'customrecord_my_custom_record',
id: '123'
});
var credId = customRecord.getValue('custrecord_cred_id');
var secureString = https.createSecureString({
guid: credId,
input: 'myInputString'
});
var response = <http://https.post|https.post>({
url: '<https://my-endpoint.com>',
body: secureString
});
}
Please note that these are simplified examples and may need to be adjusted based on your specific use case.
******
Disclaimer:
This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes.
******Celigo AI
11/18/2024, 4:05 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.899950325
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.889421821
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.881446362
Celigo AI
11/18/2024, 4:05 PMuser93865
11/18/2024, 4:07 PMrico
11/18/2024, 8:51 PMuser93865
11/19/2024, 8:49 AM