Visual Builder

Get Involved. Join the Conversation.

Topic

    sriram iyer
    Validate Input Values against HCM using REST
    Topic posted October 10, 2018 by sriram iyerRed Ribbon: 250+ Points, tagged Action Flows, REST, SaaS Integration, Validation 
    149 Views, 7 Comments
    Title:
    Validate Input Values against HCM using REST
    Summary:
    How to validate input values in VBCS against HCM using REST Services?
    Content:

    I have created a Service provider that is used to fetch person data from HCM. There is a query parameter passed to the rest service to filter the output for a Single person.

    I have created a form in VBCS where a user will enter a Person Number. When the user exits this field, I want to invoke the Rest Service to validate if the Person Number is a valid Person Number in HCM and show the First and Last Names in 2 display only fields on the form.

    Is this possible? If so, how do I do this?

    Thanks

    Sriram Iyer

    Version:
    Version: 18.3.3

    Comment

     

    • Shay Shmeltzer

      You can attach an event to the "value" event of the field and in there call the REST service and parse the response.

      Here is a basic intro to working with REST services in VBCS:

      https://blogs.oracle.com/shay/working-with-rest-post-and-other-operations-in-visual-builder

      The first part shows a similar scenario.

    • sriram iyer

      Hi Shay,

      I tried to follow the attached blog and created all the pre-requisites to invoking the Rest Service from HCM. However, when I assign one of the JSON elements to a different Input field on the page, the Page Item disappears from the screen as soon as I assign a value to it.

      Please see the attached video to see what happens.

      https://drive.google.com/file/d/14ebB5moBeDV7q3-KyCscwIxQx1HHGtHK/view

       

      Thanks

      Sriram Iyer

       

      • Shay Shmeltzer

        If you switch to the code view - is the field still there?

        Does the field show up after you invoke the REST service and populate the results into the variable?

        Does it help if you switch from an inputText component to an outputText component (for read only data).

    • sriram iyer

      The field is there in the Code view.

      <div class="oj-flex">
          <oj-label id="oj-label-669721332-1" for="oj-input-text-669721332-1" class="oj-flex-item oj-sm-12 oj-md-2">Search Person</oj-label>
          <oj-input-text id="oj-input-text-669721332-1" class="oj-flex-item oj-sm-12 oj-md-4" value="{{ $page.variables.PersonNumberS }}" on-value-changed="[[$listeners.ojInputText6697213321Value]]"></oj-input-text>
      </div>
      <div class="oj-flex">
          <oj-label id="oj-label-669721332-2" for="oj-input-text-669721332-2" class="oj-flex-item oj-sm-12 oj-md-2">Input Text</oj-label>
          <oj-input-text id="oj-input-text-669721332-2" class="oj-flex-item oj-sm-12 oj-md-4" value="{{ $page.variables.HCMPersonInfo.items[0].FirstName }}"></oj-input-text>
      </div>
      

      The field does not show up after the Rest call executes on the Input field.

      There is not OutputText component. Do you mean Text Area or something different?

    • Shay Shmeltzer

      Is the REST endpoint that you are invoking returning a single record or multiple records?

      If it is a single record - is it marked that way in the end point definition?

      Looking at the video it seems like that end-point was marked as returning an array.

      • sriram iyer

        It is set to return a single record. The HCM Rest call returns an array but we are using a query to filter the results to get only a single row as shown below.

        https://cba.fa.us1.oraclecloud.com/hcmRestApi/resources/11.13.18.05/emps?q=PersonNumber={personNumber}

        • Shay Shmeltzer

          Looks like the issue is with assigning a value from an array directly to a single field in the UI.

          Instead get the value from the array into a regular single record object variable.

          Then assign that single variable to your field.

          That should fix this.