DocId retrieval block

How to correctly implement the first practical assignment block:

My script does not return errors but also does not execute:

const docID = ss.getDocIdByIds('current.sys_db_table_id', 'current.sys_id');
const approval = new SimpleRecord('sys_approval');
approval.addQuery('item', docID);
approval.query();
approval.comments
ss.info("docID - " + docID)
current.state = '7';
current.closure_code = 'denied';
current.closure_notes = approval.comments;

current.update();

I see several obvious errors in the code.

  1. Line 5 is clearly unnecessary—likely causing the code to stop executing.
  2. Additional conditions need to be added for filtering, as we specifically need rejected approvals.
  3. current.update()—within workflow blocks, there is no need to use the update() method.

Instead, they probably meant to write

approval.next()
2 Likes

Removed the fifth line
Removed update()
Added the following as the second line:

ss.addErrorMessage(docID);

But no message appears after clicking Reject on the portal.

I haven’t noticed the error in the very first line; the parameters are passed as strings. It should be like this:

const docID = ss.getDocIdByIds(current.sys_db_table_id, current.sys_id);

3 Likes