Simultaneously add a record in two applications

When a new record is added in AP20, this script automatically adds the same record in PO10.

function FORM_OnAfterTransaction(data)
{
    // was transaction successful?
    if (formState.agsError)
    {
        return;
    }

    const sMsg = lawForm.getMessage();
    if (sMsg === "Add Complete - Continue")
    {
        let sVendorGroup = lawForm.getDataValue("VEN-VENDOR-GROUP");
        let sVendor = lawForm.getMessage();
        sVendor = sVendor.substr(sVendor.indexOf(" ") + 1, sVendor.length);
        sVendor = sVendor.substr(0, sVendor.indexOf(" "));

        let sAGSCall = portalWnd.AGSPath;
  sAGSCall += "?_PDL=" +  portalWnd.oUserProfile.getAttribute("productline");
        sAGSCall += "&_TKN=PO10.1&_EVT=ADD&_LFN=ALL&_TDS=IGNORE&FC=A";
        sAGSCall += "&POV-VENDOR-GROUP=" + sVendorGroup;
        sAGSCall += "&POV-VENDOR=" + sVendor;
        sAGSCall += "&_OUT=XML&_EOT=TRUE";

        let sAGSInfo = portalWnd.httpRequest(sAGSCall);
        sAGSInfo = (sAGSInfo ? new portalWnd.DataStorage(sAGSInfo) : null);
        if (!sAGSInfo || sAGSInfo.status > 400)
        {
            return;
        }

        const sFldNbr = sAGSInfo.getElementValue("FldNbr", 0);
        const sMsgNbr = sAGSInfo.getElementValue("MsgNbr", 0);
        const sMessage = sAGSInfo.getElementValue("Message", 0);
        portalWnd.cmnDlg.messageBox(sFldNbr + ", " + sMessage + ", " + sMsgNbr);
    }
}