Hi,
I don't know whether the answer is correct or not, but in RIA the answer is like this.
To create a custom button in the UI and make a GET API call to fetch the entity URI, you can follow these steps. Below is a modified and more detailed version of the script, including error handling and additional comments for clarity:
Steps:
-
Add a Custom Button in the UI Configuration:
Define a custom button in the UI configuration with a unique ID, label, and action.
-
Fetch the UI Configuration:
Use UI.getConfiguration() to retrieve the current UI configuration.
-
Get the Entity URI:
Use UI.getEntityUri() to fetch the URI of the current entity.
-
Make a GET API Call:
Use UI.api() to make a GET request and fetch the entity details.
-
Validate the Entity:
Check the entity's productType and identifier.id to ensure they meet your criteria.
-
Trigger a Webhook (Optional):
If the validation is successful, trigger a webhook or perform any other action.
-
Error Handling:
Add error handling for API calls and validation.
JavaScript Code:
let button = {
"point": "com.reltio.plugins.ui.button",
"id": "com.reltio.plugins.CustomButton",
"class": "com.reltio.plugins.ui.actions.CustomAction",
"label": "Custom Button",
"action": {
"files": ["https://your-script.js"]
}
};
UI.getConfiguration()
.then(function (jsonUiConfiguration) {
let entityUri = UI.getEntityUri();
UI.api(entityUri, "GET")
.then(function (response) {
let entity = response.data;
if (entity.productType === "your-product-type" && entity.identifier.id === "your-identifier-id") {
console.log("Validation successful. Entity matches the criteria.");
} else {
console.error("Validation failed. Entity does not match the criteria.");
}
})
.catch(function (error) {
console.error("Error fetching entity details:", error);
});
})
.catch(function (error) {
console.error("Error fetching UI configuration:", error);
});
------------------------------
Varsha Periyasamy
MDM Developer
Majix Solutions Inc
------------------------------