Nintex Workflow – MSDN Hexadecimal use in a Nintex Workflow

There are a number of places on MSDN, where the values you pass to a SharePoint web service are shown in hexadecimal form. This is all good if you are developing in one of the .Net languages as developers would know what that means. But when you are trying to make a call to something like the Permissions web service (AddPermissions web method), then 0x00040000 really means nothing to the Workflow designer.

Remember that these fields really do take a numeric value and not a text value. 0x00040000 needs to be converted to a decimal value (eg. 262144) to be used correctly.

You can do this using the calculator provided with your Operating System.

Open up the calculator and set it to “Programmer” mode. Here you can select “Hex” mode and you can then enter the 0x00040000. Although it’ll come up as 40000.

Now that you have entered your Hexadecimal number, you can click on the “Dec” option to change it to a decimal number.

You can now use this number in your web service call.

The other thing to remember, is that if one of these fields can be multiple values, then you need to do some calculation.

For example, if you want to give a user the following permission AddAndCustomizePages and ApplyThemeAndBorder permissions then you do an “add” :
AddAndCustomizePages : 0x00040000 (262144)
ApplyThemeAndBorder : 0x00080000 (524288)
Hex Result : 0x000C0000
Decimal Result : 786432

So you put the 786432 into the field you need.

Is there a way in Nintex Workflow where we can let our workflow do this?

Out of the box, there isn’t an easy way to do this. But with a little work we can make it possible in Nintex Workflow.

Our options are to either create a Custom Nintex Workflow action (overkill), or create a Nintex Workflow Inline Function. The advantage of using the Inline functions of Nintex Workflow, is that we can either use something already provided to us by an existing assembly in the GAC, or we could create our own.

For this issue, we’ll use something that Microsoft provides.

Convert.ToInt32

This static method can convert hexadecimal strings to integers (numbers). As this will be available on any server that .Net is installed, which is every SharePoint server, we can just add this to our Nintex Workflow database.

What we need to do, is open up SQL Management Studio, expand the Databases option, and then expand the NW2007DB database. This is the Nintex Workflow database, and the StringFunction table is what we are interested. Here we add our new Inline function.

If you want the SQL Insert Script for this :

INSERT INTO [NW2007DB].[dbo].[StringFunction]
           ([FunctionAlias]
           ,[MethodName]
           ,[AssemblyName]
           ,[Namespace]
           ,[TypeName])
     VALUES
           ('fn-ConvertToInt'
           ,'ToInt32'
           ,'mscorlib'
           ,'System'
           ,'Convert')

Another way to add an Inline function, is to use the NWAdmin.exe command line utility that gets installed with Nintex Workflow :

NWAdmin.exe -o AddInlineFunction -functionalias FunctionAlias -assembly Assembly Name -namespace Namespace -typename TypeName -method MethodName

In our case, we would run it this way :


NWAdmin.exe -o AddInlineFunction -functionalias fn-ConvertToInt -assembly mscorlib Name -namespace System -typename Convert -method ToInt32

ow if we want to use this Inline function, we use the Build Dynamic String action.

Here we are calling the fn-ConvertToInt Inline Function, passing in what we see from the MSDN site for SPRights. In this example, we are working with giving the user/group the permission of

AddAndCustomizePages

, which according to the MSDN site, is actually hex 0x00040000. We are also passing in 16 into our Inline Function, as that it was tells our static method that we are converting a text string which is hexadecimal format, into an Integer.

We can then use the Convert Value action to convert the text we received, back to a Number workflow variable, if we need to do any calculations on it, or we can simply use the text returned, and put it into our Call Web Service action SOAP configuration.

It’s as simple as that. A new Inline Function, and we now open up Nintex Workflow with new functionality it didn’t have before.

Leave a Reply

Your email address will not be published. Required fields are marked *