FieldName: Not a Valid Parameter Error

In one of my custom form I have configured custom fields to display identity list. whenever I touch the identity list dropdown it throws exception.

Could anyone help?

I have attached the rule part and error screen and ui view for reference.

Rule part:


<Field columnSpan="4" dependencies="selection,userId" displayName="Application" dynamic="true" hidden="true" name="ownedObjectsSingle" postBack="true" type="object">
            <Attributes>
              <Map>
                <entry key="hidden" value="script:return form.getField(&quot;selection&quot;).getValue().equals(&quot;Bulk&quot;);"/>
              </Map>
            </Attributes>
            <Script>
              <Source>
                import sailpoint.object.Application;
                import sailpoint.object.QueryOptions;
                import sailpoint.object.Filter;
                import sailpoint.object.Identity;
                import sailpoint.object.Field;  
                import sailpoint.object.Form;
                import sailpoint.object.Form.Section;

                try {

                String selectionValue = form.getField("selection") != null ? (String) form.getField("selection").getValue() : "";
                if (!"Bulk".equals(selectionValue)) {
                String content ="";
                String userId = form.getField("userId") != null ? (String) form.getField("userId").getValue() : "Adam.Kennedy";
                Identity selectedUser = context.getObjectByName(Identity.class, userId);

                if (selectedUser != null) {
                QueryOptions appQueryOptions = new QueryOptions();
                appQueryOptions.addFilter(Filter.eq("owner", selectedUser));
                List applicationsList = context.getObjects(Application.class, appQueryOptions);

                Section section = form.getSection("ownedObjectsSection");

                section.setColumns(4);

                if (applicationsList != null &amp;&amp; !applicationsList.isEmpty()) {
                for (Application app : applicationsList) {

                Field f = new Field();
                f.setType(Field.TYPE_BOOLEAN);
                f.setName("app_" + app.getName());
                f.setDisplayName(app.getName());
                f.setValue(false); 
                f.setColumnSpan(2);
                section.add(f);

                String description = "No description available";
                Map descriptions = app.getDescriptions();

                if (descriptions != null) {
                if (descriptions.containsKey("en")) {
                description = descriptions.get("en");
                } else if (!descriptions.isEmpty()) {
                description = descriptions.values().iterator().next();
                }
                }

                // Add the description below the application name with proper indentation and italic styling
                content += "&lt;div style='margin-left: 40px; font-style: italic;'>";
                content += "Description: " + description;
                content += "&lt;/div>";

                Field identityField = new Field();
                identityField.setType(Field.TYPE_IDENTITY);
                identityField.setName("identitySingle" + app.getName());
                identityField.setDisplayName("");
                identityField.setFilterString("inactive==true");
                identityField.setValue("");
                identityField.setColumnSpan(2);
                section.add(identityField);

                }
                } else {
                log.error("No applications found for this user");
                }

                } else {
                log.error("User not found: " + userId);
                }
                } else {
                log.info("Selection is Bulk, skipping application objects generation.");
                }
                } catch (Exception ex) {
                log.error("Error retrieving data: " + ex.getMessage());
                }

              </Source>
            </Script>
          </Field>

Ui VIew:

Error Message:

Hi @shruthi_m
Can you please check the below things once

Ensure that the field name specified in form.getField(“fieldname”) matches exactly with the name attribute of the corresponding element in your form XML.

Use form.getFieldValue(“fieldname”) instead of form.getField(“fieldname”).getValue(). The getFieldValue() method directly retrieves the value of the specified field without requiring an additional .getValue() call.

Double-check for any typos or case sensitivity issues or null checks

Hi @shruthi_m,

Can you check the log trace and if possible, share the same to get more insight into the issue?

Thanks

Error log

form error.log (8.9 KB)

Hi Shruthi,

To boil down the problem, Could you comment the new field creation code in your rule and retry if it works.

<Field columnSpan="4" dependencies="selection,userId" displayName="Application" dynamic="true" hidden="true" name="ownedObjectsSingle" postBack="true" type="object">
            <Attributes>
              <Map>
                <entry key="hidden" value="script:return form.getField(&quot;selection&quot;).getValue().equals(&quot;Bulk&quot;);"/>
              </Map>
            </Attributes>
            <Script>
              <Source>
                import sailpoint.object.Application;
                import sailpoint.object.QueryOptions;
                import sailpoint.object.Filter;
                import sailpoint.object.Identity;
                import sailpoint.object.Field;  
                import sailpoint.object.Form;
                import sailpoint.object.Form.Section;

                try {

                String selectionValue = form.getField("selection") != null ? (String) form.getField("selection").getValue() : "";
                if (!"Bulk".equals(selectionValue)) {
                String content ="";
                String userId = form.getField("userId") != null ? (String) form.getField("userId").getValue() : "Adam.Kennedy";
                Identity selectedUser = context.getObjectByName(Identity.class, userId);

                if (selectedUser != null) {
                QueryOptions appQueryOptions = new QueryOptions();
                appQueryOptions.addFilter(Filter.eq("owner", selectedUser));
                List applicationsList = context.getObjects(Application.class, appQueryOptions);

                Section section = form.getSection("ownedObjectsSection");

                section.setColumns(4);

                if (applicationsList != null &amp;&amp; !applicationsList.isEmpty()) {
                for (Application app : applicationsList) {

                //Field f = new Field();
                //f.setType(Field.TYPE_BOOLEAN);
                //f.setName("app_" + app.getName());
                //f.setDisplayName(app.getName());
                //f.setValue(false); 
                //f.setColumnSpan(2);
                //section.add(f);

                String description = "No description available";
                Map descriptions = app.getDescriptions();

                if (descriptions != null) {
                if (descriptions.containsKey("en")) {
                description = descriptions.get("en");
                } else if (!descriptions.isEmpty()) {
                description = descriptions.values().iterator().next();
                }
                }

                // Add the description below the application name with proper indentation and italic styling
                content += "&lt;div style='margin-left: 40px; font-style: italic;'>";
                content += "Description: " + description;
                content += "&lt;/div>";

                //Field identityField = new Field();
                //identityField.setType(Field.TYPE_IDENTITY);
                //identityField.setName("identitySingle" + app.getName());
                //identityField.setDisplayName("");
                //identityField.setFilterString("inactive==true");
                //identityField.setValue("");
                //identityField.setColumnSpan(2);
                //section.add(identityField);

                }
                } else {
                log.error("No applications found for this user");
                }

                } else {
                log.error("User not found: " + userId);
                }
                } else {
                log.info("Selection is Bulk, skipping application objects generation.");
                }
                } catch (Exception ex) {
                log.error("Error retrieving data: " + ex.getMessage());
                }

              </Source>
            </Script>
          </Field>

The whole part of the form is working really fine. Only new field creation step is causing the problem. If i comment all the new field creation line there is nothing to display.

Hi @shruthi_m ,

This is causing the issue. You can comment out the line below and see if that helps.

identityField.setType(Field.TYPE_IDENTITY);

No it’s not working. if i comment this line, Field is not displaying. if i uncomment this line, i’m getting the same error