Forum Discussion
12 Replies
- Former_MemberIdeator I
Hello guys, I just want to say thanks; the AML scripts suggested were fine, but I had an issue with the source_id of the parent parts. Right now the work-around I am using is to first run a query in SQL to get the part IDs from the item numbers, copy those to a txt file, and use the txt file as the input for the batch loader. So, just a small extra-step. Thank you everyone, and Jeff from Customer Support
- GopikrishnanIdeator I
If it is one time activity fine but if it is a regular activity you can create your own action and use it in AML
Step 1: Create a C# method in ARAS named PartBOMDelete
Step 2: Copy the below method
Innovator inn = this.getInnovator();
List < string > PartIDs = new List < string > ();
var itemNumber = this.getProperty("parent_item");
string getWhereClause = "[Part].item_number IN ('" + itemNumber.Replace(",", "','")+ "')";
Item partItem = inn.newItem("Part", "get");
partItem.setAttribute("select", "id");
partItem.setAttribute("where", getWhereClause);
partItem = partItem.apply();
if (!partItem.isError())
{
int count = partItem.getItemCount();
for (int i = 0; i < count; i++)
{
PartIDs.Add(partItem.getItemByIndex(i).getID());
}
}
string partIdsInfo = string.Join("','", PartIDs);
string deleteWhereClause = "[Part_BOM].source_id IN ('" + partIdsInfo + "')";
if (!string.IsNullOrEmpty(partIdsInfo))
{
Item removeBom = inn.newItem("Part BOM", "delete");
removeBom.setAttribute("where", deleteWhereClause);
removeBom = removeBom.apply();
if (removeBom.isError())
{
return inn.newError(removeBom.getErrorString());
}
}
return inn.newResult("Part BOM deleted Successfully");Step 3: Save and Unlock the Method
Step 4: Run the below AML query whenever required in Innovator Admin
<AML>
<Item action='PartBOMDelete' type='Method'>
<parent_item>Itemnumber1,itemnumber2,itemnumber3</parent_item>
</Item>
</AML>Here we have created a custom action that will delete the Part BOM based on item number. Input here is Itemnumber1,itemnumber2,itemnumber3 and you can give any number of comma separated part number and note that it will delete only in latest generation.
Thank You
Gobikrishnan R
- Former_MemberIdeator I
Thank you very much, I will definitely give this a try. This may be an activity we use regularly so defining a method is a brilliant idea.
Kind regards,
Pmateo
- AngelaIpIdeator I
I think it´s possible to delete all elements of type 'Part_BOM' which has the source_id of your parent Part.
<Item type="Part_BOM" action="delete" where="[Part_BOM].source_id='123456....'"></Item>
Not tested! Use with care :-).
- Former_MemberIdeator I
I think I am close, I have the following:
<Item type="Part BOM" action="delete" where="Part_BOM.source_id='@1'"></Item>
The parent part number I am reading from a file, first column. I am not getting errors during execution, but the part BOM is still there (the command did not delete the BOM, I can still see it in the part). I think this line makes perfect sense so I will look into it again and see if I missed anything. I also tried the following script:
<!-- To delete a complete BOM, round 2, no errors but not working -->
<Item type="Part" where = "item_number = '@1' and is_current = '1' " action="edit">
<Relationships>
<Item type = "Part BOM" action = "delete" where="Part_BOM.source_id='@1'"></Item>
</Relationships>
</Item>Should I change my approach, or am I on the right track?
- GopikrishnanIdeator I
Hi Pmateo
It should be on opposite way. You need to use the related_id. (Source ID is ID of Parent Part and Related ID is ID of Child Part)
Example:
Parent1 --> Child1
Parent2 --> Child1
If you want to delete Child1 in Parent1 and Parent2. Use below query
<AML>
<Item action='delete' type='Part BOM' where="[Part_BOM].related_id='773D6786B7DE48439F373F59'"></Item>
</AML>Here Related ID is ID of the Child1.
Hope it helps.
Thank You
Gopikrishnan
- Former_MemberIdeator I
Thanks! I will give that a try now and see what I get. Cheers!