Skip to content

IF NOT EXISTS

Use the IF NOT EXISTS operator to skip processing if a component or subcomponent already exists in the target Vault.

RECREATE Picklist IF NOT EXISTS my_picklist__c (
   label('My Picklist'),
   active(true),
   can_add_values(true),
   can_reorder_values(true),
   Picklistentry my_first_entry__c(
     value('Entry 1'),
     order(1),
     active(true)
  ),
  Picklistentry my_second_entry__c(
     value('Entry 2'),
     order(2),
     active(true)
  )
);

The same MDL script can contain both IF EXISTS and IF NOT EXISTS operators.

ALTER Object IF EXISTS my_object__c (
   ADD Field IF NOT EXISTS my_field__c (
       label('My Field'),
       type('String'),
       required(false),
       list_column(true),
       active(true)
   )
);