External Lists (BCS)

Home Forums General discussion External Lists (BCS)

Viewing 4 reply threads
  • Author
    Posts
    • #33960
      Filipe Ribeiro
      Participant

        I’m having an issue getting values from an external list (BCS)

        Function

        function setEntidade() {

        var NIFProp = getFieldValue(“nif_ent_lista_externa”);

        var res = spjs.utility.queryItems({
        “listName”: “{87c6d972-6e38-4796-b398-05561531f36f}”,
        “query”: “<Where><Eq><FieldRef Name=’NIF’ /><Value Type=’Text’>” + NIFProp + “</Value></Eq></Where>”,
        “viewFields”: [“Title”]
        });

        var dataSourceArrayAll = res.items[0];
        countEntidades = res.count;
        alert(countEntidades);

        // Verificar se tem registos (+ que 0)
        if (countEntidades !== 0) {
        .
        .
        .
        .

        Works great on {87c6d972-6e38-4796-b398-05561531f36f} (Sharepoint list) and returns the value correctly if it exists, else, shows a warning and do stuff (like display extra fields). On the {fc1dffb1-094f-4175-bdf7-27ee2b6fdf83} (BCS) throws errors

      • #33969
        Alexander Bautz
        Keymaster

          Hi,
          In an external list you don’t always have ID as the primary key. I added support for specifying the primary key back in 2017, but haven’t documented it other than in the change log – look here for an example: https://spjsblog.com/dffs/dffs-change-log/#SPJS-utilityjs_v1312

          Alexander

        • #33979
          Filipe Ribeiro
          Participant

            Hi,

            I’m using an Entity identifier (NIF) to search for Entities in external list that have the correspondent value typed by the user in a text field, if it finds a match, get the value “Name” of that Entity into a text field on the form

          • #33981
            Filipe Ribeiro
            Participant

              Read the link you sent, so I should add the primaryKEY parameter pointing to the ID column of the external list?

              • #33983
                Alexander Bautz
                Keymaster

                  The reason you get an error in the first place is that this external list most likely do not use “ID” as the primary key. You must go to the list settings and find the internal name of the field used as primary key – it may be “item_id” or something like that.

                  Alexander

                • #33985
                  Filipe Ribeiro
                  Participant

                    And then how to proceed If I find it off course 🙂

                  • #33987
                    Filipe Ribeiro
                    Participant

                      Added primaryKey parameter after identified the primarykey in the bd the alert still fires a “-1” when searching for the typed NIF

                    • #33997
                      Alexander Bautz
                      Keymaster

                        It’s hard to tell what could be wrong, but you can try to add this to the alert:

                        alert(res.errorText);

                        Not sure if it will actually contain any errors though. You can also look at the F12 > Network tab to see if you find any errors (typically red text) when running the query.

                        If you are not able to figure it out I recommend trying to read the data using the REST API. I found this from a Google search: https://prairiedeveloper.com/2017/07/manipulating-sharepoint-external-lists-using-rest/

                        I haven’t tried it – and I don’t have any external lists to test it against so I’m afraid I cannot really help you here.

                        Alexander

                    • #34001
                      Filipe Ribeiro
                      Participant

                        I have good news. Used a cross list that has userID+PrimaryKEY from BCS and had to remake my function and it worked. It’s taking time consuming data from that external list but it is what it is. Thanks mate to pointing me to the missing piece of the puzzle :)))

                        • #34009
                          Alexander Bautz
                          Keymaster

                            Thanks for the update – I’m glad you figured it out.

                            Alexander

                          • #34011
                            Filipe Ribeiro
                            Participant

                              Alexander I cannot find the opposite of spjs.dffs.doReadOnly([“Title”]); How can one enable/edit a field

                            • #34013
                              Alexander Bautz
                              Keymaster

                                It’s just spjs.dffs.undoReadOnly([“Title”]);

                                Alexander

                              • #34015
                                Filipe Ribeiro
                                Participant

                                  silly me. thanks mate

                            Viewing 4 reply threads
                            • You must be logged in to reply to this topic.