This topic contains 5 replies, has 0 voices, and was last updated by HollieY 6 years, 11 months ago.

  • Author
    Posts
  • #21466

    HollieY

    I have a user event script that copies data from a vendor bill into a new transaction, and at the end, we want to Cancel the Vendor Bill. Void does not work because of the accounting preferences, and because the Bill is in Pending Approval status and is never approved. Does anyone know if there is a method to do this? Setting the status field with script does not work. I can change the Approval Status field to Rejected, but that doesn't actually cancel the Vendor Bill. Help with the syntax to do this would be greatly appreciated.
    This is a cached copy. Click here to see the original post.

  • #21467

    pcutler

    Can you elaborate on what you mean when you say that doesn't actually cancel the vendor bill? In my testing, rejecting the bill as follows caused it not to post and have a status of "rejected:"

    Code:

    var bill=nlapiLoadRecord(nlapiGetRecordType(), nlapiGetRecordId()); bill.setFieldValue('approvalstatus', '3'); // rejected nlapiSubmitRecord(bill);

  • #21468

    HollieY

    That's correct, that's what I'm resorting to now, but it is not exactly what they want. A rejected vendor bill can still be edited, unless I add a workflow to Lock it.

    When you look at a Vendor bill in Pending Approval status in the UI, you have a Cancel button. When you click this button, it changes the document status to Cancelled, removes the dollar amounts and does not allow editing. That's what we're looking for. I can't find a method that replicates this UI button in script.

    Thanks, Hollie

  • #21469

    pcutler

    Got it, thanks for clarifying. Although undocumented, this works for me:

    Code:
    var bill=nlapiLoadRecord(nlapiGetRecordType(), nlapiGetRecordId()); bill.setFieldValue('cancelvendbill', 'T'); nlapiSubmitRecord(bill, true, true);

  • #21470

    gerson.rodriguez

    Hi HollieY, I have a unrelated question for you? Any plans to move to SS 2.0 ?

  • #21471

    HollieY

    Mr. Cutler, you are marvelous. Thank you, it was just what the doctor ordered. And Gerson, yes, plans to move to SS 2.0 but I have not overcome the learning curve yet!

    Hollie

You must be logged in to reply to this topic.