Sitemap

Showing posts with label UCM Rules. Show all posts
Showing posts with label UCM Rules. Show all posts

Sunday, April 5, 2015

UCM: Computing Derived Metadata Values with Idoc Script

SCENARIO:
Compute the value of the Comments metadata dynamically during the check-in process. The Idoc Script code will put into the Comments metadata the number of empty metadata.

1. In the Edit Rule Field xComments window, verify that the Is derived field check box is selected. Click Edit.



2. The Edit Derived Value window appears. Click the Custom tab. Verify that the Custom check box is selected. Write the code below:

<$emptyFieldsCount = 0$>
<$emptyFieldsNames = ""$>
<$count = 0$>
[[%Get the list of custom and components metadata%]]
<$executeService("GET_METADEFS")$>

[[%Parse all custom and components metadata%]]
<$loopwhile rsNumFields("MetaFieldInfo")-1 >= count$>
     [[%Get the metadata field number: count%]]
     <$metadataName = rsFieldByIndex("MetaFieldInfo",count)$>
     [[%Get the value of the metadata number: count. The value is in the "#active" ResultSet%]]
     <$metadataValue = getValue("#active",metadataName)$>
     [[%Check if the value is empty%]]
     <$if strEquals(metadataValue,"")$>
          <$emptyFieldsCount = emptyFieldsCount + 1$>
          <$emptyFieldsNames = metadataName & " " & emptyFieldsNames$>
     <$endif$>
     [[%Increase counter to parse next metadata field%]]
     <$count = count + 1$>
<$endloop$>

[[%Force the derived value of the xComments metadata using the keyword "dprDerivedValue"%]]
<$dprDerivedValue = "User : <b>" & dDocAuthor & " </b> did not enter values for the following <b>" & emptyFieldsCount & "</b> custom and components metadata: " & emptyFieldsNames & "."$>

UCM: Group Metadata Fields using Global Rules

SCENARIO: Group the date fields of Release Date and Expiration date.

1. Create a new rule in Configuration Manager applet.




2. Click the Fields tab.



3. Repeat the above step for Expiration Date. Navigate to Check In Page to see the results.


UCM: Validating file extension

1. Enter "IsDpSubmitErrorFatal=true" in the general configuration, and restart the server.
2. Create a global rule, with the activation conditions of "OnSubmit" for "Check In New" and "Check In Selected".
3. In the rule's "Side Effect" section, add the following code.

<$trace("#all", "#console")$>
<$strFileName=strReplace(primaryFile,".",",")$>
<$trace(strFileName, "#console")$>
<$exec rsMakeFromString("rsTempFile",strFileName,"ext")$>
<$exec rsSetRow("rsTempFile", rsTempFile.#numRows-1)$>

<$if strTrimWs(rsTempFile.ext) like "exe"$>
   <$abortToErrorPage("\n\nEXE files are not allowed.")$>
<$endif$>

Now using this way, we won't be able to restrict checking in exe files using DIS. For this, you have to change the idocScript code in the custom tab.

Before:
 ( (dpEvent like "OnSubmit") and
 (dpAction like "CheckinSel" or dpAction like "CheckinNew"))

After:
 ( (dpEvent like "OnSubmit" or dpEvent like "OnImport") and
 (dpAction like "CheckinSel" or dpAction like "CheckinNew" or dpAction like "NoAction"))