Forum Stats

  • 3,769,282 Users
  • 2,252,942 Discussions
  • 7,874,977 Comments

Discussions

Issue while retrieving value of custom entity attribute using JS customization.


Hi,

I have used JS customization for displaying an entity table with the details of 15 attributes in horizontal table format.

In the validate function, for invoking custom input controls on page submission I have written code for getting values, but when we click on "next", values are not retrieved/set in the desired attribute.

Please refer attached students.txt (js code) file & screenshot images for your quick reference.

Error description:

support property or method 'getValue'

TypeError: Object doesn't support property or method 'getValue'

  at validate

(http://localhost:9010/web-determinations637616938815891922/resource/TabularEntityDisplay/en-US/students.js?id=9033913081247388:61:8)

  at

e.prototype.handleCustomControlValidate

(http://localhost:9010/web-determinations637616938815891922/staticresource/interviews.js?id=e0dd2ae5cba68348:1:50687)

  at

e.prototype.validateControl

(http://localhost:9010/web-determinations637616938815891922/staticresource/interviews.js?id=e0dd2ae5cba68348:1:367213)

  at Anonymous

function (http://localhost:9010/web-determinations637616938815891922/staticresource/interviews.js?id=e0dd2ae5cba68348:1:503189)

  at

e.prototype.fullValidation

(http://localhost:9010/web-determinations637616938815891922/staticresource/interviews.js?id=e0dd2ae5cba68348:1:503121)

  at Anonymous

function

(http://localhost:9010/web-determinations637616938815891922/staticresource/interviews.js?id=e0dd2ae5cba68348:1:503853)

  at

t.prototype.doAfterWhatIf

(http://localhost:9010/web-determinations637616938815891922/staticresource/interviews.js?id=e0dd2ae5cba68348:1:148893)

  at

e.prototype.submit

(http://localhost:9010/web-determinations637616938815891922/staticresource/interviews.js?id=e0dd2ae5cba68348:1:503826)

  at

e.prototype.submit (http://localhost:9010/web-determinations637616938815891922/staticresource/interviews.js?id=e0dd2ae5cba68348:1:179222)

  at

e.prototype.onClick

(http://localhost:9010/web-determinations637616938815891922/staticresource/interviews.js?id=e0dd2ae5cba68348:1:170449)

When we click on "next", values are not retrieved/set in the desired attribute.


Answers

  • Richard Napier
    Richard Napier Member Posts: 301 Gold Badge
    edited Jul 12, 2021 11:13AM

    Hi There

    There was only one screenshot attached but it appears the main problem is the need to access instance-specific information for the validation - rather than using control.getValue() you can use interview.getValue("attribute", "entity", "instance") as in the example below, where a custom Entity Collect is validating a row of data in a similar scenario as your code example.

    Check the structure of the getControls array and you will find the instanceid for each set of controls for an instance.


    Hope this helps, if not please come back and tell us more!

    Regards

    Richard

    Aaron Houston - Houston Technologies LLC
  • Aarti Marne
    Aarti Marne Member Posts: 3 Green Ribbon

    Hi Richard,

    Thanks for your response. We were trying to access instance-specific information for the validation - rather than using control.getValue() we used interview.getValue("attribute", "entity", "instance") as in the example above, but when we click on "next", values are not retrieved/set in the desired attribute.

    Please find the attached policy model. Could you please provide us the source code/Policy model for the same?


  • Richard Napier
    Richard Napier Member Posts: 301 Gold Badge
    edited Jul 13, 2021 8:58AM

    Hi

    There are issues with your code. I appreciate that some of these may simply be because you are showing a simple extract of a more complex scenario, I am only commenting what I see in the code.

    1 -You do not populate the User Interface with the values of the attributes of any existing instances in the Mount key.

    2 -You are not setting the value of any attributes in your code. I don't see any setValue() happening. So the values of the attributes will remain unknown.

    3 - You'll need to both extract and display the errors from the validation to make it clear to the user what is going on. For example, in the raw output from your console you can see the errors returned by OIA because none of your attributes have their value set in the code:

    4 - There also seems to be some confusion about getControls(). It returns an array of controls, per row. So in your case you will have 15 array members per row. So getting the length of the array will give you the number of rows. Getting the length of an instance of the array will always give you 15, since there are 15 controls for the attributes.

    5 - The validate Key in your Entity Collect lets you return true or false if the control content is validated. I don't see you extracting the values of the instance(s) and validating them. So right now the validation is not doing anything, nor are you returning error messages or a true/false value to the engine.

    I'll reach out to you individually.

    Regards

    Richard

    Aaron Houston - Houston Technologies LLC