Reputation: 21
Im trying to display a confirmation message when a record is correctly saved and an error message when its not.
But when I try to save the script I get
SuiteScript 2.x entry point scripts must implement one script type function
appears and i don't know why. Here is the script:
/**
* @NApiVersion 2.x
* @NScriptType ClientScript
*
*/
define('[N/ui/message]', function(message){
function saveRecord(context){
var currentRecord = context.currentRecord;
var pName = currentRecord.getValue('name');
var pAge = currentRecord.getValue('custrecord_p_age');
var pLastName = currentRecord.getValue('custrecord_plastname');
if(pName != null && pAge != null && pLastName != null ){
var confirmationMsg = message.create({
title: 'Enhorabuena',
message: 'La persona ah sido ingresada con exito',
Type: message.Type.CONFIRMATION
});
confirmationMsg.show({
duration: 5000
});
return true;
}else{
var errorMsg = message.create({
title: 'Enhorabuena',
message: 'La persona ah sido ingresada con exito',
Type: message.Type.ERROR
});
errorMsg.show({
duration: 5000
});
return false;
}
}
return{
saveRecord: saveRecord
}
});
Upvotes: 1
Views: 1029
Reputation: 764
Change
/** *@NApiVersion 2.x *@NScriptType ClientScript * */
to (remove the extra * towards the end of the tag)
/**
*@NApiVersion 2.x
*@NScriptType ClientScript
*/
Also change
define('[N/ui/message]', function(message){
to (move the single quotes to inside the brackets)
define(['N/ui/message'], function(message){
Upvotes: 3
Reputation: 11
Try a stripped down version in the debugger with "Require." Your code seems fine. Also write it in Visual Code so you can see the formatting. Take out the functionality and see what is missing in structure for suitescript 2.0, example:
/**
* @NApiVersion 2.x
* @NScriptType Restlet
*/
define(["N/log"], function(log) {
function dostuff(context) {
//do stuff
}
return {
post: dostuff
};
});
Upvotes: 1