Netsuite casetaskevent value not accepted - netsuite

I'm taking over an existing setup and trying to update a form by added a new option for the user. I need to have casetaskevent set to a value but when I attempt to process it like this:
timebillRec.setValue ({
fieldId: 'casetaskevent',
value: taskid,
ignoreFieldChange: true
})
I get the error: You have entered an Invalid Field Value 673 for the following field: casetaskevent
I think the person before me set acceptable values for casetaskevent but I can't for the life of me figure out where that's set. Based on docs, this is a standard id I'm targeting for timebill.
Where can I updated the accepted values?

Related

How to move sublist fields created from User Event script

I added a sublist field on a transaction. For instance a Sales Order. When you add the field via user event script, it positions the field at the end of the sublist. Is there a way to position the field? This can't be accomplished in the UI as the field is added via script. It's a select type field, so I am trying to modify the list values with client script and can only do that if the field is created in my user even script. My code works perfectly fine, it's just the field is at the end of the sublist line(far right and have to scroll). I am using SuiteScript 1.0 but am open to using 2.0 if I need to.
This is for suitescript 2.0
This has sort of turned into two questions so I will give an answer for one and then the solution, for clarity. The short answer is you cannot move a sublist field when created in a user event (however there is a solution to that.)
you can add a sublist field by getting the sublist and using the sublist.addField method.
function beforeLoad(context){
var form = context.form;
var sublist = form.getSublist({
id : 'item'
});
sublist.addField({
id: 'fieldid you want to use for script reference ect.',
type: serverWidget.FieldType.CHECKBOX, //any supported TYPE
label: 'Label users will see in sublist'
});
}
If done this way, there will be a new column on the end of the items sublist that cannot be moved.
To be able to move the location of the column do the following.
Navigate to
Customization
Lists, Records, & Fields
Transaction Line Fields
add a new field and apply to the sublist you want it used on.
you can assign and id which will be prefixed with custcol so start your id with an _ and give it a name.
Once this is complete you can access the field by id and change the value in your user event script before load
function beforeLoad(context){
var form = context.form;
var sublist = form.getSublist({
id : 'item'
});
sublist.setSublistValue({
id: 'customcol_id_created_in_ui',
line: 1, //line you want to access if needing to set all you will have to loop through and set each one.
value: "your value"
});
}
If you go to the API reference and look at the ui/serverWidget module and navigate to sublist you can find all of the methods and options for manipulating sublist there.
In SuiteScript 2.x you would use the N/ui/serverWidget module, create the field and then use the Form.insertField(options) method, passing in the field you created as options.field and the existing field which you want to insert your field before as options.nextfield. Note that Form refers to the form object passed to the user event script in the scriptContext.
i don't believe there is a SS1.0 equivalent.

NetSuite Suitescript 2.0 How can I access custom item options records?

I have a problem that I'm trying to solve in a roundabout way since the straightforward way didn't work.
The task: Retrieve the customizable item options off of a purchase order item (using SuiteScript 2.0).
The partial solution: Currently, I extract the itemId off the PO using
po.getCurrentSublistValue({ sublistId: 'item', fieldId: 'item' });
Then I load the item and extract the item options IDs and labels using
var optionIds = item.getValue({ fieldId: 'itemoptions' });
var optionLabels = item.getText({ fieldId: 'itemoptions' });
For item options that aren't List/Record type, (like freeform text personalization), I can then loop through the item options and extract their text off of the PO item using the following code.
for (var j = 0; j < optionIds.length; j++) {
var option = po.getCurrentSublistText({
sublistId: 'item',
fieldId: optionIds[j].toLowerCase()
});
if (option !== null) {
log.debug({title: 'option found', details: optionLabels[j] + ': ' + option});
}
}
The issue: When the item option is a List/Record type, both getCurrentSublistText and getCurrentSublistValuereturn the internal ID of the list selection. For instance, if I have a custom item option for Shirt Color, and it uses the custom list Color, with Red being internal ID 2, then if my PO has an item with red shirt color on it, the option label will be "Shirt Color", but instead of "Red," the option will be 2, the internal ID from the Color list. I have no idea why getCurrentSublistText doesn't work for this use case, but I've accepted it, and I'm looking for a workaround.
My thought was, since the item option is a record in the UI (my field explorer extension says it has recordType:"itemoptioncustomfield"), I could just load it up using the option ID that I have, and if it has fieldtype:"SELECT", I would get the internal ID of the List/Record selection (fieldId: selectrecordtype) then use search.lookupFields to get the actual value of my item option, instead of the internal ID. The only issue is, I can find no way to load (or search on) an item option. The record type does not seem to exist in SuiteScript (I believe in Suite Talk it does though). Is this a possible task? Even if my workaround can't work, is there another better workaround that I'm not seeing?
Thanks in advance, I'm at a loss here.
Edit: Just to add further attempts, I found the Field.getSelectOptions() function today which looked really promising, since it would list all the select options of the item option and their values I would think. I tested it out on some other more basic fields on the order and it worked, however when I tried using getCurrentSublistField on the item option field (just as I used getCurrentSublistValue and getCurrentSublistText, the field returned was null, so looks like that is another dead end.

How to handle inventory details, getting an error?

This is my code:
var invAdjRec = nlapiCreateRecord('inventoryadjustment');
var lotNumber = "lot123456";
invAdjRec.setFieldValue('account', '850');
invAdjRec.selectNewLineItem('inventory');
invAdjRec.setCurrentLineItemValue('inventory', 'item', '2904');
invAdjRec.setCurrentLineItemValue('inventory', 'location', '3');
invAdjRec.setCurrentLineItemValue('inventory', 'adjustqtyby', '10');
var inventoryDetail = invAdjRec.createCurrentLineItemSubrecord('inventory','inventorydetail');
inventoryDetail.selectNewLineItem('inventoryassignment'); inventoryDetail.setCurrentLineItemValue('inventoryassignment', 'issueinventorynumber', lotNumber);
inventoryDetail.setCurrentLineItemValue('inventoryassignment', 'quantity', 10);
inventoryDetail.commitLineItem('inventoryassignment'); inventoryDetail.commit();
invAdjRec.commitLineItem('inventory');
nlapiSubmitRecord(invAdjRec);
This is my error:
Please enter value(s) for: Serial/Lot Number
Looks like, according to that error message, you are just missing: serialnumber.
invAdjRec.setCurrentLineItemValue('inventory','serialnumber',lotNumber);
The issueinventorynumber field is a select field of a inventorynumber record and expects an internal id passed in. If the lot you wish to set exists, you can examine an existing record that uses it to obtain the id. If the Lot Number does not yet exist, you may not be able to create it.
In your script, you use issueinventorynumber field id as the quantity to be adjusted, but this can only be used for negative inventory adjustments. For positive inventory adjustments, you need to use receiptinventorynumber instead
There's another field not listed in the record browser that must be set:
subrecordInvDetail.setCurrentSublistValue({
sublistId: 'inventoryassignment',
fieldId: 'receiptinventorynumber',
value: serialNumber
});

is there a quick method to return saved data to its default value in mongoose.js

In my User Schema I have various fields with various default values. By example, see a few fields below:
acceptedStatus: {
type: String,
trim: true,
default: 'no' //possibilities (no, yes, thinkingAboutIt, yesInFuture)
}
Is there a way to quickly return the saved data for a particular field to its default value without explicitly doing it like
user.acceptedStatus = 'no';
and, if so, is there a way to return all fields that carry default values to their original status. Thanks for your help. There are times when I need to quickly do this, and didn't know if there were any methods I am missing.
One way could be that you store schema in an object, then from that object you can easily come to know what property have defaults.

Netsuite Sales Order - set a field value based on another field

I am trying to check my online po field to see if it is empty. If it is, I want it to check the check box when the user saves.
Here is what I have so far:
function postSourcing(type){
var onlineID = nlapiGetFieldText('onlinePO');
if(onlineID == null) {
nlapiSetFieldValue('exportCheck', true);
}
}
The error I got was "You have entered an Invalid Field Value true for the following field: exportCheck". The field exportCheck is a custom field check box. Any help is much appreciated!
When using Suitescript - for setting checkbox field use the string 'T' for true and 'F' for false.
nlapiSetFieldValue('exportCheck', 'T');

Resources