Deletion Of Types

From Pengower
Jump to: navigation, search

When allowing a user to delete a type you need to be mindful of the impact the deletion may have on other types.

One way to enforce referential integrity would be to prevent the deletion of a type if it has any children associated with it, as in the following example:

1
2
3 Set itm = Current_Item
4
5 Set section = Do Current Section
6
7 // check for children
8 Set tmpArr = itm["Organisations_"]
9 If (tmpArr.Count > 0)
10 Do Set Section Params Item = itm, Name = section
11 Report = "<span style='color:red'>Cannot delete a Reseller with Organisations</span>"
12 Output = itm
13 Return_Ok
14 EndIf
15
16 Set tmpArr = itm["Phone Numbers_"]
17 If (tmpArr.Count > 0)
18 Do Set Section Params Item = itm, Name = section
19 Report = "<span style='color:red'>Cannot delete a Reseller with assigned Phone Numbers</span>"
20 Output = itm
21 Return_Ok
22 EndIf
23
24 // delete children
25 Set tmpArr = itm["Reseller Users_"]
26 Do Delete Objects Params Objects = tmpArr
27 // delete reseller
28 Do Delete Objects Params Objects = itm

See Also

Types

How to create Types