Sunday, March 6, 2016

Delete AOT Object via Code X++

// Delete AOT Object via Code X++

//Sample 1
tatic void TestJob_San(Args _args)
{
    #AOT
    TreeNode treeNode;
    TreeNode treeNodeTable; ;
    treeNode = TreeNode::findNode(#JobsPath);
    treeNodeTable = treeNode.AOTfindChild('Job1');
    treeNodeTable.AOTdelete();
}

//Sample 2
static void DeleteTables(Args _args)
{
    TreeNode tree1, tree2;
    ;
    tree1 = TreeNode::findNode("Data Dictionary\\Tables");
    if (tree1 != null)
    {
        tree2 = tree1.AOTfindChild("tablename");
        if (tree2 != null)
        {
            tree2.AOTdelete();
        }
    }
}

//Sample 3
static void Job1(Args _args)
{
    UtilIdElements utilElement;
    ;
    ttsbegin;
    select utilElement
        where utilElement.name == 'myElementName'
        && utilElement.utilLevel == utilEntryLevel::cus // any layer
        && utilElement.recordType == utilElementType::Table; // object type
    if (utilelement)
    {
        utilElement.delete();
        ttscommit;
        info('Record should be deleted now.');
    }
    else
    {
        ttsAbort;
        info('Could not delete record, or it was not found.');
    }
}

No comments:

Post a Comment

Copy Markup charges while posting purchase invoice using X++

 Copy Markup charges while posting purchase invoice using X++ Class: Important: Code logic is just for Reference.  New class => Duplicate...