Skip to content

SFPageBase labelGetter() should use layoutItems.label instead of layoutComponents..labelΒ #17

@shawnjburke

Description

@shawnjburke

Using the TestZeus sample project for a proof of concept against our custom SalesForce organization. In our configuration, on the Accounts page, when you click New, we use a custom form.

image

Leveraging the ObjectListPage class and the formValueFiller(label, value) method I can fill in some fields such as the AccountName. Great! When I tried to get the Phone field on the page it crashes. Examining the list of labels, note that it is called Account Phone not Phone.

Label and types are : Account Manager ["Reference"]
Label and types are : Account Phone ["Phone"]
(not the entire list, just a sample)

On the screen though, it shows Phone. I examined the Json returned from the UI API

"layoutItems": [ {
	"editableForUpdate": true,
	"editableForNew": true,
	"layoutComponents": [{
			"componentType": "Field",
			"apiName": "Phone",
			"label": "Account Phone"
		}
	],
	"label": "Phone",
	"lookupIdApiName": null,
	"sortable": false,
	"required": false
}

To me it would appear that it's using the layoutComponents.label incorrectly. Instead it should use the label field of the parent layoutItems .

This pattern was also present for the field Parent Account. In the UI API Json it would have Parent Account ID in the layoutComponents.label field.

"layoutItems": [{
	"editableForUpdate": true,
	"editableForNew": true,
	"layoutComponents": [{
			"componentType": "Field",
			"apiName": "ParentId",
			"label": "Parent Account ID"
		}
	],
	"label": "Parent Account",
	"lookupIdApiName": "ParentId",
	"sortable": false,
	"required": false
}

My thoughts are that this type of detail may only come out in a customized organization and not noticeable against a developer instance.

I have drawn this conclusion after examining the labelGetter() syntax

public static void labelGetter() throws Exception {
        String labelpath = "$..[?(@.editableForUpdate == true)].layoutComponents..label";
        JSONArray listofduplicatelabels = (JSONArray)JsonPath.read(uiapi_record_json, labelpath, new Predicate[0]);
        LinkedHashSet<String> labels = new LinkedHashSet();

        for(int i = 0; i < listofduplicatelabels.size(); ++i) {
            labels.add((String)listofduplicatelabels.get(i));
        }

        listoflabels = new ArrayList();
        listoflabels.addAll(labels);
        System.out.println("Labels are " + labels);
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions