How to Add a Simple Action Button to Call API Functions in Windchill
Hello Everyone,
I'm working with Windchill 13.0 and need to add a simple action button to the Windchill interface that can call my custom API functions.
Here’s what I want to achieve:
1) Add a button to the Windchill UI.
2) When the button is clicked, it should trigger a JavaScript function that calls a Windchill OData API.
Here’s an example of the API function I want to call(will be using a java version of this function):
async function getParts() {
const apiUrl = "http://windchill.gosaas.io:80/Windchill/servlet/odata/v6/ProdMgmt/Parts?$count=false";
const username = "ahsan";
const password = "Tartan123";
const basicAuth = 'Basic ' + btoa(username + ':' + password);
try {
const response = await fetch(apiUrl, {
method: 'GET',
headers: {
'Authorization': basicAuth,
'Content-Type': 'application/json',
'Accept': 'application/json'
}
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const data = await response.json();
return data;
} catch (error) {
console.error('Error fetching parts from Windchill:', error);
throw error;
}
}
I’m not sure how to add a custom button to the Windchill UI and link it to this function. Could anyone provide a step-by-step guide or any example code to help me achieve this?
Thank you in advance for your assistance!
Best regards,

