Create a UI action to enable creating knowledge articles from HR cases
Create a UI action to add the Knowledge check box to the HR case form.
始める前に
Ensure that the Developer Application is set to Human Resources: Core.
手順
- Navigate to All > System UI > UI Actions.
- Click New.
-
Fill in the following fields.
表 : 1. UI Action form Field Description Name Create Knowledge Table HR Case Action name create_knowledge - Select the Client check box.
- Select the List v3 Compatible check box.
- Select the Form button check box.
- In the Onclick field, enter createKnowledgeClient().
- In the Condition field, enter gs.getProperty("sn_hr_core.enable_kcs_hr") == 'true' && new global.CSMTableMapUtil (current).findMapByName("sn_hr_core.hr_case_kcs_article") && new global.KBKnowledge().canCreate().
-
In the Script field, enter the following code.
function createKnowledgeClient() { if (g_form.modified) { alert(new GwtMessage().getMessage('You have unsaved changes. Please save them to continue.')); }else{ //Call the UI Action again but skip the 'onclick' function gsftSubmit(null, g_form.getFormElement(), 'create_knowledge'); //MUST call the 'Action name' set in this UI Action } } //Code that runs without 'onclick' //Ensure call to server-side function with no browser errors if (typeof window == 'undefined') CreateKnowledgeServer(); function CreateKnowledgeServer(){ current.update(); var map = new global.CSMTableMapUtil (current); map.findMapByName("sn_hr_core.hr_case_kcs_article"); var targetURL = map.getTargetURL(); var referenceLink = "&sysparm_collection=sn_hr_core_case&sysparm_collectionID="+current.sys_id+"&sysparm_collection_key=task&sysparm_link_collection=m2m_kb_task&sysparm_collection_related_field=kb_knowledge&sysparm_referring_url=sn_hr_core_case.do%3fsys_id%3d"+current.sys_id; if(targetURL) action.setRedirectURL(targetURL[0]+referenceLink); } - Click Submit.