For scenarios where the user would like to create a new Opportunity record via portlet without having to show in the portlet the other mandatory fields of the record, such as that of Department, Location and Class fields, this article may be applicable.
Note that the if a user is to use a Quick Add portlet in creating an opportunity record, where the said record have mandatory fields that are not shown in the portlet, an error will be thrown upon clicking the Save button, stating that the mandatory fields should be populated.
Note that the record creation process will not push through, and no script will be triggered, unless all of the mandatory fields were populated on the Quick Add portlet.
As an alternate solution, the user can create a custom Portlet script that would call a Suitelet which would create the opportunity record.
Below is a sample script:
function quickAddOpportunityFormPortlet(portlet, column) {
portlet.setTitle('Quick Add: Opportunity');
portlet.addField('title', 'text', 'Title');
portlet.addField('entity', 'select', 'Company', '-2').setMandatory(true);
portlet.setSubmitButton(nlapiResolveURL('SUITELET','customscript_mysuitelet', 'customdeploy1'), 'Save', '_hidden');
}
function mySuiteLetQuickAdd(request, response) {
if (request.getMethod() == 'GET') {
} else {
var opp = nlapiCreateRecord('opportunity');
opp.setFieldValue('entity', request.getParameter('entity'));
opp.setFieldValue('title', request.getParameter('title'));
// Sets the location to a default value based on their business logic
opp.setFieldValue('location', '1');
var oppID = nlapiSubmitRecord(opp, true);
nlapiLogExecution('DEBUG', 'ID', oppID);
}
}
This is related to Enhancement#263418.
No comments:
Post a Comment