Anyone here worked on tht weeekly timesheet record...
# general
s
Anyone here worked on tht weeekly timesheet record? The new one with the ID of timeitem? I have trouble getting or setting the value of the sublist in beforeload… Basically I have two objects, one is from a form since I will be adding a custom column Then the newRecord, in which I would access that custom column to set a sublistvalue But I am getting these two behaviors If getting and setting from the newRecord context, it says not a function If getting and setting from the form object, I could access the values and set them however any value I set the custom column just always have undefiend
b
what does your code look like
s
this`var objRecord = scriptContext.newRecord`
var lineCount = objRecord.getLineCount({"sublistId": "timeitem"});
var recSublist = objRecord.getSublist({sublistId: 'timeitem'})
var custpage_clientContractField = objSublist.addField({
id : 'custpage_clientcontract',
type : serverWidget.FieldType.SELECT,
label: 'Client Contract'
})
var nativeCustomerAgreement = scriptContext.newRecord.getSublistValue({
sublistId: "timeitem",
fieldId: "custcolrt_timesheet_client_contract",
line:  0
});
log.debug('native field', nativeCustomerAgreement)
var custcolCustomerAgreement = scriptContext.newRecord.getSublistValue({
sublistId: "timeitem",
fieldId: "custpage_clientcontract",
line: 0
});
log.debug('custom field', custcolCustomerAgreement)
scriptContext.newRecord.setSublistValue({
sublistId: 'timeitem',
_`fieldId: 'custpage_clientcontract',`_
value: nativeCustomerAgreement,
line: 0,
ignoreFieldChange: true
b
your code is unusual, I wouldnt expect a sublist to already have values set
dont expect to do anything but set default values for fields in beforeLoad
s
the sublist method works, but i am not able to set a value to the column - it goes undefind so the whole idea of this is the user event beforeload will create a new column to be added to the sublist, then I have a client script that adds values to that sublist column, and then assigns the selected value to a native field in the UI which is hidden in the form, I do that because we can’t filter the native field in netsuite UI and it doesnt allow manipulation via script, unless created via script. i have accomplished the above requirement, however I noticed that upon saving of the line or record, after refresh the values set by the script doesn’t save and it won’t commit line - then i was told this is standard behavior now, what i wanted to add to the beforeLoad is if the native column is not empty which means i already have a value - i would assign it to the custom column. for reasons that the user might want to check on what they previously entereed
message has been deleted
b
have you tried hadcoding the value?
s
yes - it still gives undefined. i have used setsublistvalue and setsublistext hence i tried using the record object
b
what did your hard code attempt using Sublist.setSublistValue look like
s
let me go back a bit
b
you dont add select options to your select field
s
right… i was thinking about that… but if I do that won’t that mess up my client script?
b
you cant set a value to a select field that has no options
s
right, the Sublist method does not have a getSublistText, I can do that with the Record method and if I add the value and text to the select options I think it should work i have the same code in my client script
sublist.insertSelectOption({
value: clientAgreementID,
text: clientAgreementName,
});
so I can do addselectoptions in beforeLoad and the values are there but that requires the user to go in and select the dropdown… what I need to achieve is to have a value selected there in view and edit context so the user knows what was previously selected henc I was going with the setSublistValuee
b
add the select option, then use Sublist.setSublistValue
s
something like this?
if (!nativeCustomerAgreement) {
log.debug('condition inside', 'native field is empty')
} else {
log.debug('condition inside', 'native field is not empty')
custpage_clientContractField.addSelectOption({
value: 'b',
text: 'AAAA'
// ignoreFieldChange: true
})
objSublist.setSublistValue({
id: 'custpage_clientcontract',
line: 0,
value: custpage_clientContractField
})
}
b
custpage_clientContractField
is a serverWidget.Field
the value parameter for setSublistValue does not work with a Field
s
so I need to use the record sublist?
b
what does the documentation for Sublist.setSublistValue say to use for the value?
s
hmmm it says string
but if I use any “string” it says undefined
b
use a string that matches the select option you add
s
ohhh, my bad. that worked. thank you so much, appreciate your help with this.