Skip to Content
Author's profile photo sakshi sawhney

Using Java Script in SAP Adobe forms to dynamically select Logo / Image on the basis of a field value

Hi All,

Below document provides step by step guideline as to how Script Option can be used to select Logo based on the value of a text field in SAP Adobe forms . Here we will make use of Java Script.

Business Scenario:

Suppose a Client has more than one company code and logo for each Company code is different.

Requirement is to have a Logo on the form based on the Company code.

Example : Company Code Details are as follows:

Company Code Logo
110 /wp-content/uploads/2013/04/110_201365.png
210 /wp-content/uploads/2013/04/210_201366.png
310 /wp-content/uploads/2013/04/310_201367.png

Steps to be followed are :

  1. Create a Form : Here we have a Form : ZPRMM_LOGO_TEST and respective Form Interface : ZIFMMA_LOGO_TEST .
  2. In the Interface add  im_bukrs as the importing parameter and add the importing parameter to form context.Form_Interface.png
  3. In the Form Layout : Bind the value of company code (im_bukrs) field to a Text field and set its property to Hidden.Text_Field_Binding.png
  4. Now Insert 3 Image Fields namely :
    1. Logo_110
    2. Logo_210
    3. Logo_310

within a Sub Form as Shown below.Provide the Image Mapping to the Respective fields

Logo_110 Binding.png

.And Java Script at Event : initialize for each Image field : For this select the image Field : Logo_110 as shown in figure below in Script Editor choose Language as ‘Java Script’. In the Script Editor write the code as below :


Pseudo code :

data.Main.Header.General.Info_Left.Company_Logo_Addres.Logo_110::initialize - (JavaScript, client) - " this tells /elementthe position where script is inserted
if(Company_Logo_Addres.BUKRS.rawValue != 110)     "The value to be compared will change for each Image Field 210 or 310
this.presence = "hidden";   " Set the property of the Image Field

Based on the value of im_bukrs we set the layout property of the Image Fields at runtime. Repeat the Same for other Image Fields :Logo_210 and Logo_310, compare BUKRS value with 210 and 310 respectively. And we are done with our part!

Now run the form provide the company code and see the output for different company codes.

IM_BUKRS (Company Code Value) Output
/wp-content/uploads/2013/04/demo_110_202400.png /wp-content/uploads/2013/04/op_110_202402.png
/wp-content/uploads/2013/04/demo_210_202403.png /wp-content/uploads/2013/04/op_210_202406.png
/wp-content/uploads/2013/04/demo_310_202405.png /wp-content/uploads/2013/04/op_310_202407.png

Any questions or comments are welcome!

Assigned tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Sunny Lad
      Sunny Lad

      Hi Shakshi,

      I have one query.

      When my BURKS is on master page and I am trying to display logo in subform of Child page and i am trying to change the presence of logo than it is not working.

      writing below script on initialize event of logo #child page.

      data.Main.child_page.Logo_110::initialize - (JavaScript, client)

      if(data.Main.master_page..BUKRS.rawValue != 110)  "taking full path of text field.

           this.presence = "hidden";  

      Can you please tell what wrong thing i am doing?


      Author's profile photo Prajesh Desai
      Prajesh Desai

      You can try Accessing Master Page Field on Body Page this document. In this document i covered and explained that how to access master page field on body page.

      Hope this helps.

      Author's profile photo Former Member
      Former Member

      Hi ,

      Is there possible to change the Logo base the URL name too? Im Using different Logo address in Quality and Production systems and would like to find the correct Photo address in both systems. Could you please provice Formcalc or Javascrpt code for this issue ? Thanks alot



      Author's profile photo sumit balaiya
      sumit balaiya

      hey hiĀ Prajesh,

      this tutorial is very good . but i am facing problem with image with text field its not showing any image only showing text.

      Author's profile photo sakshi sawhney
      sakshi sawhney
      Blog Post Author

      Hello sumit ,

      Could you confirm if image is visible like in my example in form builder or no ?

      If possible please could u share the screen shots.

      Thank you

      Author's profile photo sumit balaiya
      sumit balaiya

      sorry for late reply...yes its visible in form builder. But when i execute my form its only showing text showing nothing.. Please check attachment.


      Author's profile photo sumit balaiya
      sumit balaiya

      I need to show both logo conditional Plant wise.