How to implement one hit navigation
One hit navigation means if only one result found during search, the detail page of that search result entity will be opened automatically without user manual action.
See example below: after search button is clicked, the detail page of 201300024454 will be opened automatically.
You could follow the below steps to achieve: 1. You must enable one hit navigation behavior for your business role. double click “Parameter Assignment”: add a new parameter ONE_HIT_DIRECT_DISPLAY with value TRUE 2. Implement your search button event handler as below. Use navigate_if_result_is_unique to trigger the potential navigation. method EH_ONSEARCH. DATA: lv_result TYPE REF TO if_bol_entity_col, lr_comp TYPE REF TO CL_ZONEHITN_BSPWDCOMPONEN_IMPL, lv_onehit_navigation TYPE abap_bool. lr_comp ?= me->comp_controller. lv_result = zcl_jerry_tool=>get_query_results( me->typed_context->search->collection_wrapper ). IF cl_crm_uiu_one_hit_direct_nav=>navigate_if_result_is_unique( iv_value_help_mode = abap_false ir_result_col = lv_result ) = abap_false. lr_comp->typed_context->searchresult->collection_wrapper->set_collection( lv_result ). ENDIF. endmethod. You should put the detail page of search result into a separate UI component and include it into search component via component usage. Expose its main window as interface view and inbound plug, so that one search result is unique, the detail page of that component could be chose and navigated via UI framework. 3. Create an entry for the detail component in “Define Work Area Component Repository“: 4. Define Navigation Bar Profile: choose Navigation bar profile TPM-PRO, double click on “Define Generic Outbound Plug Mappings”: Configure the target ID defined in step3 here Now you could test in UI.
http://bit.ly/2hNAkGF #SAP #SAPCloud #AI
Content democratization: How the Internet is fueling the growth of creative economies
#ICYDK: http://bit.ly/2hMJD9C
Part 2: Start Workflow from your HTML5 application
In my previous blogs, you learnt how to integrate your custom application UI as user task in workflow that is then shown in My Inbox. While this is one part of the story, in another part you may want to start the workflow from your external user interface or pre-built application.
Assuming you have modelled the workflow and deployed it in SAP Cloud Platform. Now, how will the workflow be triggered ? – It could be via an external application or other SAP Cloud Applications. For example: when the user form is filled and a button is clicked then a workflow has to be started – say an approval workflow for leave or approval for travel expenses or workflow for asset repair or extended approval workflow from SAP SuccessFactors application when the new hire is created etc.
For former, this is possible with small configuration in your external application and using Workflow Runtime AP. For latter, you can refer my blog where I have explained how can you start a workflow from SAP Cloud Platform Integration service.
Here you go:
Assuming you have an SAPUI5 application and you want to start the workflow by some action, say a button click, from that application.
* Open the SAPUI5 application in SAP WebIDE Full-stack
* Define the destination route in neo-app.json in routes array: { “path”: “bpmworkflowruntime”, “target”: { “type”: “destination”, “name”: “bpmworkflowruntime”, “entryPath”: “/workflow-service” }, “description”: “Workflow Service Runtime” }
* In the button action in Component.js or view.controller.js or where you have the action implementation, (a) first write the javascript function to call the API for fetching the XSRF token and (b) next write the javascript function to call the API to start the workflow with desired initial payload _fetchToken: function() { var token; $.ajax({ url: “/bpmworkflowruntime/rest/v1/xsrf-token”, method: “GET”, async: false, headers: { “X-CSRF-Token”: “Fetch” }, success: function(result, xhr, data) { token = data.getResponseHeader(“X-CSRF-Token”); } }); return token; }
» where URL is /rest/v1/xsrf-token. You can find the destination in Connectivity –> Destinations in SAP Cloud Platform cockpit.
» bpmworkflowruntime is the default destination with ApptoAppSSO authentication type
» For more information on the workflow runtime API, refer the official API documentation _startInstance: function(token) { var model = this.getView().getModel(); var inputValue = model.getProperty(“/text”); $.ajax({ url: “/bpmworkflowruntime/rest/v1/workflow-instances”, method: “POST”, async: false, contentType: “application/json”, headers: { “X-CSRF-Token”: token }, data: JSON.stringify({ definitionId: , context: { text: inputValue } }), success: function(result, xhr, data) { model.setProperty(“/result”, JSON.stringify(result, null, 4)); } }); }
» is the ID workflow. You can open the workflow SAP Web IDE and see the properties of the workflow to find the ID.
» inputValue is the initial payload with which the workflow starts. It can be your entire application model, a subset of your model or a completely new model.
» The only thing you have to ensure that model you pass must be of JSON type as the workflow API works on JSON body.
* Finally, implement the button action to get the CSRF token and then call the public workflow runtime API to start the workflow with the token: buttonAction: function() { var token = this._fetchToken(); this._startInstance(token); }
Once the action is performed and the workflow has started successfully, you will see the response from API as: { id =13, definitionId=LeaveRequestWorkflow, definitionVersion=2, subject=Leave Request for Alice, businessKey=11203, status=RUNNING, startedAt=2017-12-03:40:60:40.000Z, startedBy=Lorin, completedAt=null } http://bit.ly/2hMJcfu #SAP #SAPCloud #AI
