Monday, March 19, 2012

Using UCM Global Profile Rules with RIDC

The question came up on another forum:
  • Can I use profiles to validate my data input when I'm using RIDC?
Profiles can indeed be used in such a case, for example, to halt a RIDC checkin if a given metadata field is empty. 

There are a couple of prerequisite steps to follow:
  • In the Content Server general configuration, enable the following setting:
    IsDpSubmitErrorFatal=true
  • In the RIDC code, do not use CHECKIN_UNIVERSAL as the service call, but use CHECKIN_NEW instead.  (CHECKIN_UNIVERSAL doesn't load the profile engine.) 

Now build the rule solution.  The following bare-bones example makes the "Comments" field "required" to be a non-blank value for a new checkin.
  • In Configuration Manager. create a new global profile rule.  Set the activation conditions to "on submit" and "checkin new".
  • Add the "Comments" field to the rule.  In the "Use Derived Value" section, add the following code in the custom section:

    <$if strEquals(strTrimWs(#active.xComments),"")$>
     <$abortToErrorPage("Cannot submit item without any comments provided.")$>
    <$endif$>
  • Save the rule and exit Configuration Manager.
  • To test the solution, execute your RIDC code without providing any comments.  If you didn't provide any comments, the error message thrown is "Cannot submit item without any comments provided."