Home General Discussion

add objectpicker through custom tasks

Mehwish_ShahidMehwish_Shahid Customer IT Monkey ✭

Hello,

Is it possible to add controls like objectpicker/userpicker/etc. programmatically through a custom task? I've only seen them used in the custom form .js file, where you define them in the columnFieldLists. But I would like to add them through custom tasks (for example a task that opens a window with some objectpicker fields to fill in), but can't figure out if and how you could do it.

Thanks in advance.

Answers

  • James_JohnsonJames_Johnson Customer Advanced IT Monkey ✭✭✭

    Hi @Mehwish_Shahid

    It is possible through custom JS to do object pickers. What page(s) are you trying to implement this on? Or if you could provide a little more info on what you're trying to do that could be helpful.

    James

  • Mehwish_ShahidMehwish_Shahid Customer IT Monkey ✭

    Hi @James_Johnson

    We are trying to do this for a custom form of a CI class. So I made a task to create a new CI object („Buchungsposition“) through a popup window. It looks like this:


    The html code for the input field looks like this:

            <input

              data-role="autocomplete"

              name="Anlagennummer"           

              data-text-field="DisplayName"

              validationMessage="{0} eingeben!"         

              data-bind="value: attachementNumber, source: attachementNumberSource"

            />


    The autocomplete input fields are bound to kendo.data.DataSource objects in the custom task, which look like this for the above attachementNumberSource example:


    attachementNumberSource: new kendo.data.DataSource({

                    ignoreCase: true,

                    serverFiltering: true,

                    transport: {

                      read: {

                        url: "/api/V3/Config/GetConfigItemsByClass",

                        type: "GET",

                        datatype: "json",

                        data: function (options) {

                          let searchValue = options.filter.filters[0].value;

                          return {

                            userId: session.user.Id,

                            isUserScoped: false,

                            searchFilter: searchValue,

                            objectClassId: "940fb39b-4d16-65da-c063-0f1a8933c4f6"

                          };

                        }

                      }

                    },

                    sort: {

                      field: "DisplayName",

                      dir: "asc"

                    }

                  }),


    So now I can search for „Attachement“ objects by using this input and save them as attributes/relationships when creating my „Buchungsposition“ object. But Cireson’s objectpicker for example also checks whether the value you have written inside the autocomplete field exists or not, and if not, it displays the input as red like this:

    And since this is becoming more and more of a recreation of an object picker I would save time just using the existing one instead of making my own. 

  • James_JohnsonJames_Johnson Customer Advanced IT Monkey ✭✭✭

    Ah I see what you're saying. I don't think there is anyway to leverage the Cireson built objects because afaik they are built server side.

    You are pretty close to having most of the functionality there already. You could also take a look at ROToolbox script https://github.com/doyle-johnpaul/ROToolbox which has validation and I just recently made a pull request that's waiting to be merged that adds the underlining functionality when an object is selected correctly.

    Here's the link to the Cireson thread as well. https://community.cireson.com/discussion/2595/transforming-the-grid-picker/p7

  • Mehwish_ShahidMehwish_Shahid Customer IT Monkey ✭

    Oh too bad, but thank you for the links, I will take a look at them. @James_Johnson

    Another question that is related to this one. After the "Buchungsposition" object is created through the commit api we want the results to be displayed in a multipleobjectpicker on the form.

    The new object only shows up in the multipleobjectpicker list after clicking on "Save" or "Apply", but I want the picker to update/refresh after creating my "Buchungsposition" object, but before saving the form. I read that you can update form elements through viewModel.set(.....) but I'm not sure what to write in the brackets so that only the picker gets updated. Also the refresh had already worked before once (so it's definitely possible), but for some reason it stopped working and I can't figure out what the cause was, I probably modified the code too much..

Sign In or Register to comment.