Hey guys
😉 It's me again. This time it won't be about enhancing the standard content review and feedback function in SAP Enable Now with the
Content Review Wizard Extension but about our good friend SAP Companion, whose task is to provide all sorts of in-app help relevant to those who request this help. With the first part, SAP Companion has no problem: 75+ SAP applications are supported, and 3rd party products are also welcome to activate SAP Companion. However, there is still some space left for improvements in the latter part.
As we know, SAP Companion uses 4 parameters for selecting relevant learning entities to
shoot them in the face of the user (sorry, I'd been playing
Borderlands 2 too much during the New Year holidays). These parameters are:
- Product Name, i.e. SAP_S4HANA_ON-PREMISE or SFSF
- Product Version, i.e. 2021.latest or 1805
- Screen Name, i.e. Shell-home or HOME/HOME_TAB/HOME_V4
- System UI Language
Hold on! There is nothing about the user... What if multiple roles have access to the same application screen, like Employee Profile in SAP SuccessFactors, but perform different operations? Therefore, only need help with assets relevant to their role/location/position. Earlier, I showed how to
fish for additional information in SAP SuccessFactors and forward it to SAP Companion.
Now, it's time for Ariba Guided Buying
![](/legacyfs/online/storage/blog_attachments/2023/02/companion_doesnt_know.jpg)
This is how SAP Companion and Ariba probably feel when using the standard parameters.
How can we share valuable data about the person currently logged in to Ariba Guided Buying with SAP Companion?
![](/legacyfs/online/storage/blog_attachments/2023/02/flugge-1.png)
The programming language SAP Enable Now is built with?
No-no-no!!!! Not with this elven spell, but with a few lines of JavaScript code added to the standard Ariba Guided Buying Snippet and infamous
useConditions=true top secret parameter of the SAP Companion.
Step-by-step Instruction
Step 1. Follow the
SAP Companion Integration Guide for Ariba Guided Buying. After creating the
Configuration, navigate to the
Application tab, expand the
Advanced section, locate the
Parameters field at the bottom of the dialog window, and add
useConditions=true; into it.
![](/legacyfs/online/storage/blog_attachments/2023/02/useConditions.png)
Anton + useConditions = LOVE
Step 2. Let's find values describing the user in Ariba Guided Buying that we can use to increase the content relevance. Log into your Ariba Guided Buying system, and open the Google Chrome or MS Edge developer tools by pressing the
F12 key or
Ctrl+Shift+i key combination. Switch to the
Console tab in the Developer tools and run these 2 commands one by one pressing
Enter after each.
let context = JSON.parse(sessionStorage.userContext)
//press Enter
context
//press Enter
Step 3 Expand the context object by clicking on the small black triangle shape beside it. You'll see a long list of various values describing the system and the user. Write down parameters that you find helpful, i.e.,
country,
state, companyCode, userPurchaseOrg, to share with the SAP Companion to let it segregate the content for different users.
Step 4 Make a copy of the standard
Ariba Guided Buying Snippet, locate
Help4.init() function, and add a few lines similar to mine inside its body that will process previously selected Ariba Guided Buying user session parameters and set them as SAP Companion conditions.
![](/legacyfs/online/storage/blog_attachments/2023/02/ConditionsCode.png)
The code highlighted in yellow extracts the values describing the user from the Ariba session storage and saves them in variables.
The code highlighted in aqua sets the SAP Companion conditions and assigns the values saved in variables.
The highlighted code fragment in a copy-pastable format
//extracting user attributes from Ariba session and saving them as variables
let companyCode = JSON.parse(sessionStorage.userContext).companyCode;
let country = JSON.parse(sessionStorage.userContext).country;
let userPurchaseOrg = JSON.parse(sessionStorage.userContext).userPurchaseOrg;
//assigning user attributes to the SAP Companion conditions
Help4.API.setConditions({'companyCode': companyCode, 'country' : country, 'userPurchaseOrg' : userPurchaseOrg});
Step 5. Save your changes, make sure that your Ariba Configuration uses this updated snippet, and refresh the Ariba Guided Buying window where your SAP Companion is running. Open the browser developer tools and execute the command in the Console.
Help4.API.getConditions()
//press Enter
If you did everything correctly, you should see the list of conditions and user-related values gently picked from the Ariba
😉
![](/legacyfs/online/storage/blog_attachments/2023/02/getConditions.png)
Open the SAP Companion editor window. You'll see the
Conditions tab and familiar parameters you can assign to the help tile or link or the guided tour step to show them to only those who met these conditions.
![](/legacyfs/online/storage/blog_attachments/2023/02/conditionsCompanion.png)
All the best, and see you next time!