cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Business rules on fields

lardybenoit
New Contributor

Hi,

 

I am creating new instance of application object with custom fields.

I would like to define some rules on some fields in order to raise errors if one is not filled based on specific values from another one.

 

Do somebody could help me to set such kind of rules?

 

Thanks

1 Reply

lionel
MEGA
MEGA

Hello Benoit,

 

with a more precise question I could give you a more precise answer 😉 but :

 

you can explore your metaAttribute (what you call "Field") and create a Macro via the "metaAttributeUpdateTool" metaAssociation. This macro will be launched each time someone tries to modify the value of your metaAttribute.

 

Your macro must contain 2 functions.

 

The first one is :

Function AttCtl_GetDefaultKind() As String 
  'To be short, use "Edit" for string metaAttributes
  'And "ComboBox" for enumeration metaAttributes
  AttCtl_GetDefaultKind = "Edit"
End Function

 

And the second one (with the most common things you will need...)

Function AttCtl_Update(Context, Status, ErrorMessage)
  Dim myObject, myValue
  Set myObject = Context.MegaObject 'To get the object where the fiel has been modified
  myValue = Context.EditText 'What has been type by the user (modification of the field)

  If <your test here> Then 'For example, if myValue <> myObject.getProp(<myOtherField>)
    'If errorMessage is not empty, the update of the field will not be allowed
    ErrorMessage = "You have no right to use this value because..." 
  End If
End Function

 

Regards,

 

Lionel