Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
former_member659241
Participant
Introduction:

We got a requirement from one of my customers that we need to assign profile pictures and user names in SAP Design Studio. The user logs in using SAP BI Launchpad. So, based on the user we need to assign the profile pictures and user names to the user dynamically. Here, I’ve used a simple method to assign the Profile Picture to a single user. By repeating the condition used here, you can add the profile pictures of users as required. In my continuation blog, I'll be explaining about dynamically changing the user names.

Main Problem:

In SAP Design Studio, we don’t have any separate component to assign the Profile Photo for users. So, we need to plan for some other way, where we have to use some other component that could achieve this functionality.

Solution:

In this blog, I’ve explained a method to achieve the functionality of using dynamic profile pic for users by using the Image Component. The username would be fetched from the BI launchpad and based on the Username, the image of the user changes dynamically.

To achieve this follow the steps mentioned below:

1.You can either use an image in jpeg mode or can also use the image by converting it to a URI code. In case if you are going to use the URI converter, collect the Profile picture of the user and convert it to URI code, using Image to URI converter. The reason for using the URI code is that the site instantly removes the need for the need to fetch additional resources.

For example, we can use the below image:


After converting to URI code (You can refer to websites online to refer to the URI code), we get the below code:

<img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAEAAAAAAAD/2wBDAAIBAQIBAQICAgICAgICAwUDAwMDAwYEBAMFBwYHBwcGBwcICQsJCAgKCAcHCg0KCgsMDAwMBwkODw0MDgsMDAz/2wBDAQICAgMDAwYDAwYMCAcIDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAz/wAARCAAtAC0DASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpT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7KfDM3iDVbixtTaW1xrFzFM8CsFDMoiijXewUAsVJALBdoZgfoKvj85xlPE4l1KPw+Z+Z8SZtDH4pVaeyVvxb/U//2Q==" alt="" />

2. Now, include the above code in the Script file created for the Dashboard in the CSS class as mentioned in the below screenshot:


3. From the above image, you can notice that the URI code is entered in the background-image CSS command. You would need to copy the part from “data” till “alt=” part in the URI code and enter it in the above script inside the url(); part. The background repeat option is set to no-repeat to show the image only once. Also, set the background size of the image using the above script.  Here, I’ve chosen a square image of 45 X 45 pixels. Now, map the CSS Class to the image component as mentioned below. Here, I’ve created an image component named IMAGE_3:


4. Now, go to the ‘On Startup’ section of the Dashboard by clicking on the below part in the Properties section.


5. Write the below Script in the Script Editor part of the Application.


6. Refer to the below script:

if(DS_1.getInfo().user == "Administrator"){

IMAGE_3.setVisible(true);

}else{

IMAGE_3.setVisible(false);

}

In the above code, 'DS_1' is the data source and 'Administrator' is the name of the user. getInfo().user is used to compare the login username in the BI launchpad with the user who is mentioned in the Script.

IMAGE_3 is the image component we have used. I’ve just made the setVisible as true for the given user based on the condition.

7. Now, save the Dashboard and run it in BI Launchpad.


8. In order to test it, you can also test the above scenario by removing the username from the code that you have used. You would not be able to view the profile picture and user name now.


9. Thus, we can ensure that the above condition has worked out. In order to use multiple users with profile pics, we can try the nested if statement.

Conclusion:

So, in this blog, we have learned how to insert a profile pic dynamically based on the user trying to launch the dashboard using BI Launchpad. In our next blog, we can see how to dynamically change the username.

Reference:
Labels in this area