Dear Community,
Maybe I’m overcomplicating this, but for a very simple use case of producing the Initials of given user based on it’s MultiPass id, I created a function that looks like this:
@Function()
public reduceToInitials(firstName: string, lastName: string): string {
// Helper function to get the first letter of a word
const getFirstLetter = (word: string): string => word.charAt(0).toUpperCase();
// Handle compound last names (e.g., "de la Vega", "Smith-Jones")
const processLastName = (lastName: string): string => {
// Split by spaces or hyphens and take the first letter of each significant word
return lastName
.split(/[\s-]+/)
.filter(word => word.length > 2) // Ignore short prepositions like 'de', 'la'
.map(getFirstLetter)
.join(''); // Join all initials from last name parts
};
const firstInitial = getFirstLetter(firstName);
const lastInitials = processLastName(lastName);
return `${firstInitial}${lastInitials}`;
}
and…
@Function()
public reduceToInitialsColumns(tasks: ObjectSet<Task>): FunctionsMap<Task, string> {
const map = new FunctionsMap<Task, string>();
tasks.all().forEach(t => {
const assignee: Multipass = t.assignee;
const firstName = assignee.givenName;
const lastName = assignee.familyName;
map.set(t, this.reduceToInitials(firstName, lastName));
});
return map;
}
AIP Assist suggest me to import this:
import { Multipass } from "@foundry/ontology-api";
… which doesn’t exist.
What is the appropriate way to obtain attributes from a MultiPass ID using TypeScript?
Thanks