As a senior OpenText Content Server developer with expertise in version 16.2 and OScript, I’ll guide you step by step on how to find the source of a callback or code that modifies card attributes after creation. This is a common debugging and investigation task in OpenText Content Server (OTCS), and it requires a systematic approach to trace the source of the change.
Step 1: Understand the Context of the Change
Before diving into the code, you need to gather some context about the change:
- What attribute was changed? Identify the specific attribute (e.g., a metadata field, category attribute, or system attribute) that was modified.
- When was it changed? Determine if the change happens immediately after creation, during a specific event (e.g., workflow step, user action), or at a later time (e.g., scheduled task).
- Who or what made the change? Check the audit trail or history to see if the change was made by a user, a system process, or a background job.
To gather this information:
-
Check the Audit Trail:
- Navigate to the card (node) in the Content Server UI.
- Go to the "Audit" tab or use the "Functions > Audit" menu to view the audit history.
- Look for entries related to attribute updates (e.g., "Modify Attributes" or "Update Metadata").
- Note the timestamp, user, and context of the change (e.g., "System" or a specific user).
-
Check the Node History:
- If the attribute is part of a category, check the category history to see when and how the attribute was modified.
- Use the "Versions" tab or category history to identify changes.
-
Determine the Event:
- Based on the audit trail, determine the event that triggered the change (e.g., node creation, workflow initiation, or a user action like saving the card).
Step 2: Identify Potential Sources of the Change
In OpenText Content Server, attribute changes can originate from several sources. Here are the most common ones to investigate:
-
Callbacks:
- Callbacks are OScript code snippets that execute in response to specific events (e.g., node creation, modification, workflow events).
- Callbacks are often defined in the object’s subtype, category, or workflow configuration.
-
Request Handlers:
- Custom request handlers (web scripts) may modify attributes when users interact with the system via the UI or API.
-
Workflows:
- Workflow steps, initiations, or map scripts may modify attributes on associated work objects or cards.
-
Scheduled Tasks:
- Background jobs or scheduled tasks (e.g., agents) may periodically update attributes.
-
Custom Modules:
- Custom OScript modules or features installed on the system may include logic to modify attributes.
-
Web Services or APIs:
- External applications or integrations may use the Content Server API (e.g., CWS, REST API) to update attributes.
Step 3: Trace Callbacks (Primary Focus)
Since you suspect a callback is responsible for the change, let’s focus on how to trace and find the callback source. Callbacks are event-driven OScript code blocks that are executed in response to specific events on a node (e.g., OnCreate, OnModify, OnSave).
3.1 Identify the Object Type and Subtype
-
Determine the type and subtype of the card (node) whose attributes are being modified.
-
Subtypes often define custom behavior, including callbacks, so this is a critical piece of information.
3.2 Check for Callbacks on the Subtype
- Subtypes in Content Server are stored in the
DTreeCore table and are associated with OScript code in the OSpace (object space).
- To find the callbacks for the subtype:
-
Access the OSpace:
-
Look for Callbacks:
-
Trace the Callback Code:
- If the callback is inline OScript, it will be directly visible in the
Callbacks feature.
- If the callback references an external script or module, note the reference (e.g.,
$MyModule.MyFeature.MyCallback) and trace it to the corresponding OSpace or module.
3.3 Check for Category Callbacks
- If the attribute being modified is part of a category, the category definition may also include callbacks.
- To investigate category callbacks:
-
Identify the Category:
-
Inspect the Category Definition:
- Use the OSpace Browser to navigate to the
Category OSpace and find the category definition by its ID.
- Look for a
Callbacks feature in the category definition, similar to the subtype callbacks.
-
Trace Category Callback Code:
- If a callback exists, it may modify attributes during events like
OnApply (when the category is applied) or OnSave (when the category data is saved).
3.4 Check for Workflow Callbacks
- If the card is part of a workflow, the workflow definition may include scripts or callbacks that modify attributes.
- To investigate workflow callbacks:
-
Identify the Workflow:
- Check if the card is attached to a workflow (e.g., as a work object or attachment).
- Use the UI to view the workflow history or use OScript to retrieve workflow information:
Object node = $WebNode.WebNodeUtils.GetNodeByID( prgCtx, dataid )
List workflows = $Workflow.WorkflowUtils.GetWorkflowsForNode( prgCtx, node )
for Object wf in workflows
echo( "Workflow ID: " + wf.fID + ", Name: " + wf.fName )
end
-
Inspect Workflow Scripts:
- Open the workflow definition in the Workflow Designer (Administration > Workflow Administration).
- Check the following areas for scripts:
- Initiation Scripts: Scripts that run when the workflow starts.
- Step Scripts: Scripts associated with specific workflow steps.
- Map Scripts: Scripts defined in the workflow map (e.g., on transitions or events).
- Look for OScript code that modifies node attributes, such as calls to
SetAttrValue or UpdateNode.
Step 4: Enable Debugging and Logging
If the callback source is not immediately obvious, you can enable debugging and logging to trace the execution of OScript code.
4.1 Enable OScript Debugging
- Use the Content Server debugging tools to trace OScript execution:
-
Enable Debug Mode:
- Add the following URL parameter to the Content Server UI:
?debug=1.
- Alternatively, enable debug mode in your OScript code by setting the
fDebug flag in the PrgCtx:
.fPrgCtx.fDebug = true
-
Add Echo Statements:
-
View Debug Output:
- Debug output is written to the Content Server logs (e.g.,
opentext.log) or displayed in the UI if debug mode is enabled.
4.2 Enable Audit Logging
- Enable detailed audit logging to capture attribute changes:
- Go to Administration > System Configuration > Audit Configuration.
- Enable auditing for "Modify Attributes" and other relevant events.
- Reproduce the issue and check the audit logs for details.
4.3 Use the OScript Profiler
- The OScript Profiler can help trace the execution of OScript code and identify the source of changes.
- Enable the profiler in the Content Server Administration pages (Administration > System Tools > Profiler).
- Reproduce the issue and analyze the profiler output to see which scripts were executed.
Step 5: Investigate Custom Modules and Features
If the callback is not defined in the subtype, category, or workflow, it may be part of a custom module or feature installed on the system.
- Check Installed Modules:
- Go to Administration > Module Administration to see a list of installed modules.
- Review the documentation or OSpace definitions for each module to identify any custom logic that modifies attributes.
- Search the OSpace:
- Use the OSpace Browser to search for references to the attribute name or related keywords (e.g.,
SetAttrValue, UpdateNode).
- Example OScript to search the OSpace:
Object prgCtx = .fPrgCtx
Object ospaceTools = $OSpace.OSpaceTools
List ospaces = ospaceTools.GetOSpaces( prgCtx )
for String ospaceName in ospaces
Object ospace = ospaceTools.GetOSpace( prgCtx, ospaceName )
for String itemName in ospace.GetItems()
Object item = ospace.GetItem( itemName )
if ( Str.Contains( item.ToString(), "MyAttribute" ) )
echo( "Found reference in OSpace: " + ospaceName + ", Item: " + itemName )
end
end
end
Step 6: Reproduce and Test
- Reproduce the issue in a controlled environment (e.g., a development or test instance) to confirm your findings.
- If you have identified the callback or script, temporarily disable or modify it to verify that it is the source of the change.
- For example, comment out the callback code or add debug logging to confirm execution.
Step 7: Document and Resolve
- Once you have identified the source of the change, document your findings, including:
- The location of the callback or script (e.g., OSpace, module, workflow).
- The event that triggers the change.
- The business logic or reason for the change (if known).
- If the change is unintended or needs modification, work with the system administrator or development team to update the code.
Example Scenario
Let’s say you find that the attribute MyAttribute on a card is being modified immediately after creation. Here’s how you might trace it:
- Check the audit trail and confirm the change happens during the "Create" event.
- Identify the card’s subtype (e.g.,
144 for a custom document type).
- Use the OSpace Browser to navigate to
WebNodeSubTypes and inspect subtype 144.
- Find the
Callbacks feature and see an OnCreate callback that includes:
node.SetAttrValue( "MyAttribute", "NewValue" )
node.Update()
- Confirm this is the source by adding debug logging or temporarily commenting out the code.
- Document the finding and decide if the logic needs to be modified.
Additional Tips
- Use Version Control: If your organization uses version control for OScript code, search the repository for references to the attribute or callback.
- Collaborate with Admins: Work with Content Server administrators to access logs, audit trails, and system configurations.
- Leverage Support: If the issue is complex or involves third-party modules, consider engaging OpenText Support for assistance.
By following these steps systematically, you should be able to identify the source of the callback or code that modifies the card attributes in OpenText Content Server 16.2.