The CreatorCon Call for Content is officially open! Get started here.

How to make author field editable for current Knowledge Base Members?

alok_071
Tera Contributor
 
6 REPLIES 6

AshishKM
Kilo Patron
Kilo Patron

Hi @alok_071 , 

You can create ACL ( write ) for "kb_knowledge.author" and check for knowledge base membership in script part.

 

-Thanks,

AshishKM

 


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution

Hi @AshishKM ,

I have created the write ACl for author field with following advanced script but it's not working.

answer = false;
if (gs.getUser().isMemberof(current.kb_knowledge_base)){

answer = true;

}

Please refer the below link, isMemberof() method works for group based membership check, but here knowledge base managers field is a list collector type so its giving list of manager's sys_id with comma separated values, 

 

https://developer.servicenow.com/dev.do#!/reference/api/utah/server_legacy/GUserAPI#GUser-isMemberOf...

 

Use the below code in advance script and test.

 

 

answer = false;
var baseMgrList = current.kb_knowledge_base.kb_managers;
var baseMgrSysId = [];
// split the comma separated list in to aarayList
baseMgrSysId = baseMgrList.split(',');
var arrayUtil = new ArrayUtil();
//the contain method will check the logged in user sys_id in arrayList
answer = arrayUtil.contains(baseMgrSysId,gs.getUserID());

 

 

Question-> as per the KB process stage ( Draft -- - - - > Publish ) , any further update required checkout and knowledge manger can update the author in new version of KB and re-submit for approval and then publish it. Why you need to edit this author update by know manager in state other than draft. I checked KB base managers can edit this author in draft but not in published state ( OOTB).

 

Note :

gs.getUser() -> Returns a reference to the user object for the current user.

gs.getUserID -> Returns the sys_id of the current user.

contains -> Searches the array for the specified element. Returns true if the element exists in the array, otherwise returns false.

 

-Thanks,

AshishKM


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution

please accept the solution and close this open thread.


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution