Team, I have created a custom record (C) where I h...
# suitescript
a
Team, I have created a custom record (C) where I have one field that is pointing at other record as parent (P). This means that when I open the parent record (P), I can see a "Custom" sublist with the records I have created with my new custom record (C). I am trying to get to the "Custom" sublist from a User Event script (beforeLoad), but I cannot find it. Anyone dealt with this? Is there a way to access to the sublist somehow?
b
have you complete all the steps to Creating Custom Child Record Sublists
a
let me review that page, thanks
ok, I had missed step of clicking ALLOW CHILD RECORD EDITING
now I can see the sublist in the NS Field Explorer, so probably from the code too
thanks, will report back if okay from the code
hmm, not working
on a User Event script, I have this code
Copy code
function beforeLoad(scriptContext)
{
    //var form = scriptContext.form;
    var rec = scriptContext.newRecord;
    log.debug('rec', JSON.stringify(rec));
    log.debug('scriptContext.type', scriptContext.type);
    if (scriptContext.type === scriptContext.UserEventType.VIEW )
    {
        // VIEW MODE
        var numOMSDocLines = rec.getLineCount({ sublistId: 'recmachcustrecord_amp_ll_agreement_link_id'});
        //var numOMSDocLines = rec.getLineCount({sublistId: 'custrecord_abc'});
        log.debug('numOMSDocLines', numOMSDocLines);
numOMSDocLines comes to 0
ok, so, to make it work, I had to actually use record.load instead of using the context.newRecord
b
on view, the parent/child sublist is a static list sublist, which does not support suitescript
on edit, or when loading via suitescript, its a normal editor sublist that supports suitescript
a
okay, thanks a lot for the info, will keep that in mind
it is somewhat working for what I need
I needed to update one of the fields on the child sublist
as I said, on beforeLoad, I do record.load, make the changes, and save the record
what is interesting is that the updated records show up on the user screen
I think maybe because the sublist is not loaded right away, but reloaded when clicking on the tab...