Sitemap

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 & "."$>

No comments:

Post a Comment