{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":49745,"path":"source-to-pay-operations/accounts-payable-operations/post-upgrade-tasks-for-apo.md","title":"Post upgrade tasks for APO","bundle":null,"doc_type":null,"release":"australia","body":"\n# Post upgrade tasks for APO\n\nReview and complete required post-upgrade tasks after upgrading Accounts Payable Operations.\n\n## Upgrade configuration for Accounts Payable Operations integration with Document Intelligence\n\nComplete post-upgrade tasks after upgrading Accounts Payable Operations, including upgrading copied use cases to the latest Document Intelligence model.\n\n### Before you begin\n\nRole required: admin\n\nInstall the Document Intelligence for Accounts Payable Operations Content Pack from the ServiceNow® Store.\n\n### Procedure\n\n1.  Select the DO NOT USE- Invoice processing V7 use case as source.\n\n2.  Navigate to **All** &gt; **Document Data Extraction Administration** &gt; **Use Cases**.\n\n3.  Search for DO NOT USE- Invoice processing V7 and create a duplicate copy using the \\[Omitted image \"duplicate-di-usecase.png\"\\] Alt text: duplicate icon icon.\n\n4.  Save the copied use case.\n\n    Use the copied use case in flows and task definitions.\n\n5.  To upgrade the copied use case to the latest Document Intelligence model, perform the following steps:\n\n    1.  Navigate to **All** &gt; **Fix Scripts**.\n\n    2.  Search for Update DocIntel base\\_trained\\_model and select **Run Fix Script**.\n\n        The existing copied use case is updated to the latest DI base model.\n\n\n## Restructured Invoice table\n\nThe invoice and invoice line tables are restructured in the Xanadu release.\n\nBefore Washington DC release, invoice and invoice line tables were standalone tables. With Xanadu release, the following changes are done:\n\n-   The invoice table \\[sn\\_shop\\_invoice\\] extends the base invoice table \\[sn\\_fin\\_base\\_invoice\\].\n-   The invoice line table \\[sn\\_shop\\_invoice\\_line\\] extends the base invoice line table \\[sn\\_fin\\_base\\_invoice\\_line\\].\n\n\\[Omitted image \"invoice-reparenting.png\"\\] Alt text: Invoice table structure explaining the invoice table and invoice table line extending to base tables.\n\nAfter you upgrade from Washington DC to Australia release, verify that your existing invoice and invoice line data has been migrated correctly. If you notice that your invoice and invoice line tables didn’t migrate properly, use the [Now Support Portal](https://support.servicenow.com/now) to raise a case with the Technical Support team.\n\n## Run a glide fix script to migrate existing data\n\nWhen updating from Washington DC to Australia release, manually run the glide fix to update the invoice and invoice line tables to their respective base tables.\n\n### Before you begin\n\nRole required: maint\n\n### Procedure\n\n1.  Navigate to **All** &gt; **System Definition** &gt; **Fix Scripts**.\n\n2.  Select **New**.\n\n    A new Fix script record opens.\n\n3.  Open the fix script record.\n\n4.  Enter **Name** as re-parent invoice table.\n\n5.  Deselect the **Record for rollback** check box.\n\n6.  In the **Script** field, add the following code for the invoice line:\n\n    ```\n    (function() {\n                const invoiceLinetableToReparent = \"sn_shop_invoice_line\";\n                const invoiceLineNewExtends = \"sn_fin_base_invoice_line\";\n                const oldExtends = \"\";\n    var invoiceLineGr = new GlideRecord(\"sys_db_object\");\n            invoiceLineGr.get(\"name\", invoiceLinetableToReparent);\n            if(invoiceLineGr.super_class.name == invoiceLineNewExtends) {\n                gs.info(\"{0} table already reparented to {1}. No reparenting required.\", invoiceLinetableToReparent, invoiceLineNewExtends);\n                return;\n            }\n    try {\n                \n                var invoiceLinetpc = new GlideTableParentChange(invoiceLinetableToReparent);\n                var reparentInvoiceLineResult = invoiceLinetpc.change(oldExtends, invoiceLineNewExtends);\n    \n            } catch (e) {\n                gs.warn(\"Table parent change for sn_shop_invoice_line did not complete. Error: {0}\", e);\n            } \n    })();\n    \n    ```\n\n7.  In the **Script** field, add the following code for invoice:\n\n    ```\n     (function() {\n            const invoiceTableToReparent = \"sn_shop_invoice\";\n            const oldExtends = \"\";\n            const invoiceNewExtends = \"sn_fin_base_invoice\";\n    var invoiceGr = new GlideRecord(\"sys_db_object\");\n            invoiceGr.get(\"name\", invoiceTableToReparent);\n            if(invoiceGr.super_class.name == invoiceNewExtends){\n                gs.info(\"{0} table already reparented to {1}. No reparenting required.\", invoiceTableToReparent, invoiceNewExtends);\n                return;\n            }\n     try {\n                var tpc = new GlideTableParentChange(invoiceTableToReparent);\n                var reparentResult = tpc.change(oldExtends, invoiceNewExtends);\n            } catch (e) {\n                gs.warn(\"Table parent change for sn_shop_invoice did not complete. Error: {0}\", e);\n            } \n     })();\n    \n    ```\n\n8.  Select**Save**.\n\n9.  Select **Submit**.\n\n    The Fix script is created.\n\n10. Select **Run Fix Script**.\n\n    The parent invoice and invoice line tables are changed to respective base tables.\n\n\n## Run fix script for exceptions\n\nRun the fix script after upgrading to the Australia to recalculate amounts and quantities for in-process invoices with Insufficient Goods Receipt and amount line and header variance conditions.\n\n### Before you begin\n\nRole required: AP admin\n\n### Procedure\n\n1.  Navigate to **Source-to-Pay Workspace** &gt; **All** &gt; **sysauto\\_script.LIST** table.\n\n    The **Scheduled Script Executions** page appears.\n\n2.  Search for script \"APM - Recalculate In-Process Invoice Amounts and Quantity\".\\[Omitted image \"fix-script-exception.png\"\\] Alt text: Fix script for exceptions\n\n3.  Select **Execute Now** to run the fix script.\n\n\n### Result\n\nThe script ensures invoices that are in-process state are re-calculated against amount and quantity as per the logic of Insufficient goods receipt, Insufficient line and header amount variance.\n\n**Related topics**  \n\n\n[Invoice exceptions]()\n\n## Run scheduled job for cost allocation\n\nRun a scheduled job to copy cost allocations from invoice line to purchase order line when upgrading Accounts Payable Operations from lower to higher version.\n\n### Before you begin\n\nRole required: admin\n\n### Procedure\n\n1.  Navigate to **All** &gt; **Scheduled Jobs** &gt; **Update Cost Allocation for the invoice**.\n\n2.  Select the **Active** check box.\n\n3.  In the script, add the following encodedQuery:\n\n    ```\n    var encodedQuery = sn_shop.InvoiceLine.ORDER_LINE + 'ISNOTEMPTY^' + sn_shop.InvoiceLine.INVOICE + '.' + sn_shop.Invoice.STATE + 'IN' + sn_shop.Invoice.STATE_DRAFT + ',' + sn_shop.Invoice.STATE_PO_MAPPING_ERROR + \",\" + sn_shop.Invoice.STATE_SUSPECTED_DUPLICATE;\n    ```\n\n4.  Select **Save** and **Execute Now**.\n\n    During the upgrade Accounts Payable Operations, cost allocation is auto-updated when purchase order lines are mapped to invoice lines.\n\n\n"}}