×

Create a protected field 

Last updated: July 19, 2022

MA!N has an option to protect the contents of a field. For instance, when certain users aren’t allowed to change it or when the value of the field should simply be not changed when it has a certain value. To do this you can use the following code:

First we add the code to add a field called ‘ExampleField’.

<Group ID='OurExample'>
	<Data ID='Data RetrievedData'>
		<Select>
			<![CDATA[
				SELECT	TOP 1 [field]			AS	[ExampleField]
				FROM	[File]
			]]>
		</Select>
		<Columns>
			<Column ID=" ExampleField">
				<AddControl>True</AddControl>
				<ReadOnly>False</ReadOnly>
			</Column>
		</Columns>
	</Data>
</Group>

There will probably be more ‘Fields’ in the Group but for this example we just isolated our field. Next, we add the code to make the field protected. This code should be at the end of the command, so under the definition of the field.

<Process ID=' Process'>
    <DataID>Data RetrievedData</DataID>
    <Active>
        <AdjustControls>
            <Select>
	        <![CDATA[
		   SELECT	' ExampleField'		AS [Control ID]
		   ,	CASE	WHEN 	<your condition here>
		   THEN 	1
		   ELSE 	0
		   END				AS [Enabled]
		]]>
	    </Select>
	</AdjustControls>
    </Active>
</Process>

The dataID on must be the dataID the field resides in.