Creating and Managing Parent Comments in Workflow Scripts
Summary: jennifertemple1, also known as jennifertemple1, inquires about developing a workflow script task that creates a comment and retrieves its ID for future comment linking. Stefan Busch suggests modifying the script to save the comment's ID using parentComment.getId(). When jennifertemple1 experiences excessive log information, Stefan points out that the getId() method should be logged directly to avoid displaying the entire comment object. Additionally, Stefan advises updating the code due to the deprecation of certain functions, providing a new code example using the latest API documentation.
I'm exploring how to design a workflow script task that not only creates a comment but also retrieves the ID of that newly created comment (Parent), so future comments can be effectively linked to it. My current script only focuses on creating comments using:
import com.collibra.dgc.core.api.dto.instance.comment.AddCommentRequest
commentApi.addComment(AddCommentRequest.builder()
.baseResourceId(assetUuid)
.baseResourceType(ResourceType.Asset)
.content(newApprovalContent)
.build())However, I'm uncertain how to modify it to return the ID for future reference. For those who have experience in similar scenarios, how have you approached this in your scripts? What strategies or best practices do you recommend for managing parent-child comment relationships in workflows? Looking forward to hearing your insights and any code examples you might be willing to share!
Stefan Busch
·11 months ago · EditedGetting the ID of the created comment is not really hard just a little modification needed
jennifertemple1
OP11 months ago · EditedThank you so much for your help - I have implemented the changes to my script but it seems that the getId() is pulling more than just the UUID for the comment that was created:
import com.collibra.dgc.core.api.model.instance.Comment
import com.collibra.dgc.core.api.dto.instance.comment.AddCommentRequest
//Log Start Approval Comment
Comment parentComment = commentApi.addComment(AddCommentRequest.builder()
.baseResourceId(assetUuid)
.baseResourceType(ResourceType.Asset)
.content(changeApprovalContent)
.build())
//to now access the id you can use
parentComment.getId()
loggerApi.info("Parent Comment ID --------->>>> "+parentComment)
dgc.log output:
2025-10-21 15:47:15.410 [http-nio-0.0.0.0-4400-exec-44] INFO c.c.d.c.api.component.LoggerApiImpl - Parent Comment ID --------->>>> Comment{content='<b>Start Asset Approval:</b> Change to Asset: Updated the definition to be more clear', contentLastModifiedOn=null, baseResource=ResourceReferenceImpl{id=0190276d-b383-78a5-a698-167597b65d2e, resourceType=Asset, resourceDiscriminator='Asset'}, parent=null, resolved=false, mentionedUsers=[]} Resource{createdBy=664bf413-e192-4fdb-b3dc-e50075eb36ac, createdOn=1761076035375, lastModifiedBy=664bf413-e192-4fdb-b3dc-e50075eb36ac, lastModifiedOn=1761076035375, system=false, resourceType=Comment} EntityImpl{id=019a084f-bf2f-7f7e-807d-0ade7a92d77c} [authenticated_id=664bf413-e192-4fdb-b3dc-e50075eb36ac, trace_id=f772399ae3f441febb4657d6812cdb29, session_hash=4ca311ed67ac70dc0a4d92e80ffc73ab375289c0c0957eb046bf0771942ad8fa, trace_flags=01, span_id=3d2a3552a06efea6]
I also noticed in the API documentation that .baseResource items are being deprecated, so I think I need to update my script for that as well.
Stefan Busch
·11 months ago · EditedHello,
the reason why the log shows more than just the id is, because when you call the log you actually give it the comment
Instead you should give it the id like I suggested
Regarding the deprecation of the functions, the documentation suggests that you can adapt your code using the new functions, should look something like the following
I'm not a 100% sure if for the 'commentableResourceDiscriminator' the word "Asset" has the right spelling (upper + lowercase letters). You would need to test that.