SBM Javascript Get Element By ID

Hi!

I am adding a javascript code to poulate a combo-box in SBM form using a third party API and to do that I have to get that combo-box id using document.getElementByIdfunction, but I was not able to get it using the control name like  const cmbClient = document.getElementById('cmb_client') but I was able to get it using  const cmbClient = document.getElementById('11dea367-3f93-4503-813f-f44c3e570f42') which is the id that SBM generates as part of security purposes, my concern is that id will be changed I think based on the user browser on different machines , so is there a way to implement getElementById function using the ComboBox name defined in the SBM form ? or is there a way in SBM javascript to get the id of a particular field?



Thanks!


  • 0

    This is the list of the uuid's as shown in the browser inspector:


    SetFormVersion("11.4.2");
    var isPreview = false;

    InitFieldLookup({ "Fields": [
    { uuid: "newnote", name: "newnote", fid: "newnote", dbName: "_NEWNOTE" },
    {uuid:'a8467a36-f650-46c9-a0bf-1261f193d813',fid:'F23859',name:'CheckNumber',dbName:'CHECKNUMBER',type:'text',subType:'text',readOnly:false,isRequired:false},
    {uuid:'4a454e71-275d-4d7a-aa7d-f80fff1bd092',fid:'F23860',name:'FirstName',dbName:'FIRSTNAME',type:'text',subType:'text',readOnly:false,isRequired:false},
    {uuid:'8df2cf9d-507a-4dc1-8249-e79506b3ac50',fid:'F23861',name:'LastName',dbName:'LASTNAME',type:'text',subType:'text',readOnly:false,isRequired:false},
    { uuid: "daedeb88-d37f-4f81-8af9-e3519451ccd9", name: "txt_CheckNumber", fid: "daedeb88-d37f-4f81-8af9-e3519451ccd9", dbName: null, type: "edit" },
    { uuid: "28ca9718-e659-47d7-b0bc-81ccfa184f39", name: "txt_FirstName", fid: "28ca9718-e659-47d7-b0bc-81ccfa184f39", dbName: null, type: "edit" },
    { uuid: "96480a91-e47d-49af-8625-38cbd572a461", name: "txt_LastName", fid: "96480a91-e47d-49af-8625-38cbd572a461", dbName: null, type: "edit" },
    { uuid: "ecfeca77-e533-4353-b381-95b8edf49a27", name: "txt_Amount", fid: "ecfeca77-e533-4353-b381-95b8edf49a27", dbName: null, type: "edit" },
    { uuid: "ff4fbeb5-7288-4138-b847-00fb7113433b", name: "txt_RecievedDate", fid: "ff4fbeb5-7288-4138-b847-00fb7113433b", dbName: null, type: "edit" },
    { uuid: "f85e1dbe-ab02-46ba-b152-b405a8301f3f", name: "txt_LoanNumber", fid: "f85e1dbe-ab02-46ba-b152-b405a8301f3f", dbName: null, type: "edit" },
    { uuid: "a8916b17-6fbe-4ce4-9cf8-12a16c4cdab2", name: "txt_Result", fid: "a8916b17-6fbe-4ce4-9cf8-12a16c4cdab2", dbName: null, type: "edit" },
    { uuid: "11dea367-3f93-4503-813f-f44c3e570f42", name: "cmb_Client", fid: "11dea367-3f93-4503-813f-f44c3e570f42", dbName: null, type: "list" },
    { uuid: "51338e8d-b31d-4b38-9a30-4d4ebe33a6f2", name: "HTMLJavascriptWidget", fid: "51338e8d-b31d-4b38-9a30-4d4ebe33a6f2", dbName: null, type: "widget" },
    { uuid: "15881525-ea37-438b-8389-0b297c57d6ff", name: "Panel", fid: "15881525-ea37-438b-8389-0b297c57d6ff", dbName: null, type: "container" },
    { uuid: null, name: null, fid: null, dbName: null, type: null } ]}, bValidate
    );

    InitTransitionLookup({ "Transitions": [
    {uuid:'update',tid:'1',name:'Update',type:'update'},{uuid:'delete',tid:'2',name:'Delete',type:'delete'},
    { name: null, fid: null, type: null } ] }
    );


    So do these uuid's change from machine to machine

  • Verified Answer

    +1 in reply to 

    The UUIDs should not change.

    I'm pretty sure that the UUIDs of all design elements (tables, fields, forms, scripts, roles, etc) are created in Composer.  The UUIDs are part of the "blueprint" that is used to deploy the Process App to every environment.  As you know, the TS_IDs of the elements may change from environment to environment.

    In your JS, use the "_LookupField()" function to get a JSON object with the field's ID, UUID, Name or DBName from any of those values.  That function essentially returns the data that you listed. 

    Here's what the function returns for a field.  NOTE: This is in the MS Edge JavaScript debugger / developer console:

    _LookupField("Case Name")   // Field Display Name
    {uuid: '6dbda76b-e3d4-4bc6-a092-8d1d70d9aa35', fid: 'F70', name: 'Case Name', dbName: 'TITLE', type: 'text', …}
    _LookupField("TITLE") // Field DbName is "TS_TITLE"
    {uuid: '6dbda76b-e3d4-4bc6-a092-8d1d70d9aa35', fid: 'F70', name: 'Case Name', dbName: 'TITLE', type: 'text', …}
    _LookupField("6dbda76b-e3d4-4bc6-a092-8d1d70d9aa35")
    {uuid: '6dbda76b-e3d4-4bc6-a092-8d1d70d9aa35', fid: 'F70', name: 'Case Name', dbName: 'TITLE', type: 'text', …}
    _LookupField("F70") // Field TS_ID is 70
    {uuid: '6dbda76b-e3d4-4bc6-a092-8d1d70d9aa35', fid: 'F70', name: 'Case Name', dbName: 'TITLE', type: 'text', …}

  • Verified Answer

    +1   in reply to 

    I would also add that the "F" numbers change for each environment too. If you need to get the F number for a field in javascript, it looks like this:  GetFieldByName("MyFieldName").id

  • 0 in reply to   

        Thank you so much that was helpful !

  • Verified Answer

    +1 in reply to 

    By the way, there are several screens in SBM Composer where you can right-click on a list or table and select "Export".  This will save a  text "CSV" file with the names and UUIDs of the elements in the list.  I find this feature very handy for getting the list of Selections from Single-Select fields,

  • 0 in reply to 

      Nice feature, that would be helpful for the table fields. In my case I added controls from the Form Palette to the form that do not exist in the table because I will be using its UI only to poulate some data where saving info process will be done into another 3rd party table not into SBM table so no need to create a table in SBM.

  • Verified Answer

    +1 in reply to 

    It (right-click / Export...) works on the table too!! :-)