Home › Forums › General discussion › External Lists (BCS)
- This topic has 12 replies, 2 voices, and was last updated 3 years, 4 months ago by Filipe Ribeiro.
-
AuthorPosts
-
-
June 29, 2021 at 18:13 #33960
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
- This topic was modified 3 years, 4 months ago by Filipe Ribeiro.
Attachments:
-
June 29, 2021 at 21:08 #33969
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_v1312Alexander
-
June 30, 2021 at 09:50 #33979
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
-
June 30, 2021 at 09:52 #33981
Read the link you sent, so I should add the primaryKEY parameter pointing to the ID column of the external list?
-
June 30, 2021 at 10:46 #33983
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
-
June 30, 2021 at 12:09 #33985
And then how to proceed If I find it off course 🙂
-
June 30, 2021 at 12:25 #33987
Added primaryKey parameter after identified the primarykey in the bd the alert still fires a “-1” when searching for the typed NIF
Attachments:
-
June 30, 2021 at 16:30 #33997
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
-
-
June 30, 2021 at 16:48 #34001
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 :)))
-
June 30, 2021 at 19:24 #34009
Thanks for the update – I’m glad you figured it out.
Alexander
-
July 1, 2021 at 16:16 #34011
Alexander I cannot find the opposite of spjs.dffs.doReadOnly([“Title”]); How can one enable/edit a field
-
July 1, 2021 at 16:27 #34013
It’s just spjs.dffs.undoReadOnly([“Title”]);
Alexander
-
July 1, 2021 at 16:29 #34015
silly me. thanks mate
-
-
-
AuthorPosts
- You must be logged in to reply to this topic.