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

  • Author
    Posts
  • #21466 Score: 0

    HollieY
    • Contributions: 0
    • Level 1

    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 Score: 0

    pcutler
    • Contributions: 0
    • Level 1

    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 Score: 0

    HollieY
    • Contributions: 0
    • Level 1

    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 Score: 0

    pcutler
    • Contributions: 0
    • Level 1

    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 Score: 0

    gerson.rodriguez
    • Contributions: 0
    • Level 1

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

  • #21471 Score: 0

    HollieY
    • Contributions: 0
    • Level 1

    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.