UI Builder - Creating a new transform data resource
in this video we're going to create a new transform data resource we've already looked at how to use an existing data resource and looked at a lot of the data resources that are provided to us but sometimes you might need to create a new one and i think one of the most common types of data resources that our customers and partners are going to be creating are the transform data resource so the job of a transform data resource is to basically take some sort of input and then transform it or reformat it to a different output so the most common use case for this is you might have a graphql data resource you're doing a graphql query and then the results you get back are you know this json blob that's formatted in the same way that your query is so you know it may be hard to use and your component uh that you're trying to bind it to may need a different format and so that's where the transform data resource comes in you can take that you know maybe hard to use uh format and then reformat it using some javascript and then output to whatever you want your output to be so what we're going to do in this video is we're going to do a pretty simple and maybe not totally realistic use case where i want in this component i want it to say my usernames to do's and i think my username in this instant instance is brad administrator so it would say brad administrators to dos so right now i have this title and i also have a data resource that i'm using to grab the user information of the logged in user so this lookup user data resource and i can see that i've got this property in here called brad administrator so what i could do is i could just make my title say brad administrator by binding it to this value but i want to do something a little more complex and also have it say some text and so i can't do that without you know doing something else to it so there are a few different ways you could do that you could run a client script you could probably use client state variable but what we're going to do is we're going to use this use case to demonstrate how you would create a transform data resource so let's get started i'm going to click add and then i'm going to click new and it's going to ask me what kind of data resource i want to create there's the five different kinds i'm going to select transform and it's going to give me this screen so let's call it um transform user name title is are a bunch of words um so the next thing i need to do is give it a property so i have a property already configured so let's zoom in a little bit uh so the property is going to be the input for the data resource i can have multiple properties so you know if if this data resource was a query my properties could be like a table name and query parameters but for this one it's just going to be that display name so i'm going to give it a name user display name a label so what shows up on the form and then there's some other attributes of this property field type is an important one so this is going to be a string i think it would also be really common for this to be an object and i'm going to make it mandatory then the other thing i need to do is to write a script so you can see in my script here my input is going to be an object that has all of these properties that i define so my display name is going to be input dot user display name which matches to the name of this property and then i'm just going to create a message and return this message so it should say system or brad administrators open to do's so let's go ahead and save this and then we'll go into ui builder and we're going to try to use it let's zoom back out all right so let's go here and add our newly created data resource you'll notice i'm in my simple to do spoke so that was created in my simple to do spoke so transform username title that looks right and when i click on it it's going to tell me hey you have this user display name input and you're outputting the the whole string so let's go add all right and it's telling me i don't have permission to select this data resource well that's odd acl failed for data broker so one of the steps when you're creating a new data resource is that you have to create an acl for it and let's walk through that so i'm going to need the sys id of my data resource and then we're going to create an acl so i'm going to elevate my roles and then we'll go acl we'll hit new the type is going to be ux data broker so there are going to be some places in the platform where you see the term data broker it is synonymous with data resource i think we renamed them from data brokers to data resources at one point so just know that and then for the name you may have to use the blue button to change the mode from the drop downs to the string field but in the name i'm just going to put the sys id that i copied from that data resource and then i need to give it some sort of role so i'm just going to say snc internal because i know that all of my users in this instance have that role so we'll submit and then let's hop back over to ui builder uh let's let's save it uh oh i don't need to refresh it saved it for me so uh we did get some output so our step that we need now is i need to input that username from the lookup user into this property that i defined so i know that that is lookup user one and then let's see what we have so full name i think is what we wanted and that looks right so we input brad administrator our transform data resource took this and then also added the last part of the text here and our last step is that we need to go ahead and bind that output to the title and our to-do's so the name of this data resource was transform username title so data resource transform username title and that was the output and it worked here so we have the right name let's save it and test it and that did it so obviously this was a really simple use case but i just wanted to demonstrate some of the steps right you have to create your transform data resource you have to define your properties and then write some sort of script and then that last step is that you have to create a read acl or an execute acl so that ui builder can read your data resource
https://www.youtube.com/watch?v=4IXL7Ki2oxI