This topic contains 6 replies, has 0 voices, and was last updated by karenn 7 years ago.

  • Author
    Posts
  • #17841

    karenn

    Hello all

    Another 1.0 to 2.0 conversion issue.

    We need to be able to allow editing of the cost column in the item list of an estimate while adding an item for a specific item. In 1.0 we used

    nlapiDisableLineItemField(‘item’, ‘costestimaterate’, false);

    Documentation says objField.isDisabled = false; is the equivalent but I have had no luck in getting a valid objField.

    How do I enable or disable a field in the current sublist line?

    Thanks!
    This is a cached copy. Click here to see the original post.

  • #17842

    JohnCCole

    In the context of a custom sublist field the below has worked for me, I’m assuming would work for costestimaterate. Also, I think you would likely want this code to run happen after the item field on sublist changes and on line init

    Code:
    var rec = scriptContext.currentRecord;
    var sItem = rec.getCurrentSublistValue({sublistId:’item’,fieldId:’item’});
    // Check the item is set to prevent exception
    if(sItem.length > 0){
    var fld = rec.getSublistField({sublistId:’item’,line:rec.getCurrentSublistIndex({sublistId:’item’}),fieldId:’costestimaterate’});
    if(fld != null)fld.isDisabled = false;
    }

  • #17843

    karenn

    Yeah that is what I was trying and I was afraid the error was because we need to be able to do this as the line is being created. We need to be able to add a cost for this one SPECIAL item as the item is being added to the Sales Order.

    It is becoming very annoying not being able to do things we used to be able to do in 1.0. 2,0 is taking steps backwards


    JohnCCole replied on 11/02/2017, 06:07 AM: I was revisiting my post while you were commenting, see the revision above. If you check for the existence of the item on the sublist and run the code on fieldChange of the sublist item field and on lineinit it still doesn’t work?

  • #17844

    karenn

    No joy.

    still same error

    undefined(postSourcing)

    JS_EXCEPTION SSS_INVALID_SUBLIST_OPERATION CurrentRecord.getSublistField


    JohnCCole replied on 11/02/2017, 11:19 AM: Hmmm, have you tried the same kind of operation on a custom column field or maybe even say the amount field as a test. My own experience has been a custom record with a custom sublist and had no issue. I will do a small test on an estimate and see if I get the same kind of error you are.

  • #17845

    karenn

    Same error with other column field

  • #17846

    JohnCCole

    Ok I had to chance to look and custom record with custom sublist things work fine but built-in item sublist this code seems to fail on SS 2.0. I think it’s a bug, but I did remember that SuiteScript 1.0 and 2.0 are running at the same time so this code in postSourcing while not recommended seems to work.

    Code:
    if(scriptContext.sublistId==’item’){

    if(scriptContext.fieldId == ‘item’){

    setTimeout(function(){window.nlapiDisableLineItemField(‘item’, ‘amount’, true);},10);

    }

    }

  • #17847

    karenn

    Looks like that might work. Guess we have to do what we have to do sometimes. Thanks so much for all the help!

You must be logged in to reply to this topic.