Set Multi Lookup value - Error in Edit-Form with special characters
Hi there,
i'm setting a cross-site lookup with multi-value option by code in the new form:
It works.
The value from "titleField" is "InputSystem <-> OutputSystem"
But, if i try to update a item, i receive an error:
"Something went wrong..."
"The data source control failed to execute the update command"
The data from "fd.field("WikiKapitel").control('data')" in edit-view:
after set manuale (dropdown):
The problem seems to be because of the "<" & ">" characters...
How to fix this issue?
i'm setting a cross-site lookup with multi-value option by code in the new form:
Code: Select all
var data = {};
var titleField="WikiChapterTitle"; //internal field name for lookup-column
data["Id"] = item.ID;
data[titleField] = item[titleField];
fd.field("WikiKapitel").value([data]);
The value from "titleField" is "InputSystem <-> OutputSystem"
But, if i try to update a item, i receive an error:
"Something went wrong..."
"The data source control failed to execute the update command"
The data from "fd.field("WikiKapitel").control('data')" in edit-view:
Code: Select all
[
0: {
[functions]: ,
Id: "174",
WikiChapterTitle: "InputSystem <-> OutputSystem"
},
length: 1
]
Code: Select all
[
0: {
[functions]: ,
__metadata: { },
ID: 174,
Id: 174,
WikiChapter: " 4. 39.",
WikiChapterTitle: "InputSystem <-> OutputSystem"
},
length: 1
]
How to fix this issue?
Hello ragesoft,
I'm sorry for the delayed reply.
Could you please give more details about the error: "Something went wrong..."
"The data source control failed to execute the update command".
When do you see this error?
Is it occur only when 'WikiKapitel' field value is 'InputSystem <-> OutputSystem'.
Could you please send the screenshot of the error and the fields to have a clear picture.
I'm sorry for the delayed reply.
Could you please give more details about the error: "Something went wrong..."
"The data source control failed to execute the update command".
When do you see this error?
Is it occur only when 'WikiKapitel' field value is 'InputSystem <-> OutputSystem'.
Could you please send the screenshot of the error and the fields to have a clear picture.
The problem is with the escaped values.
So if i would add the field with ">" or "<" it dosnt work!
in Edit form if i call "fd.field("WikiKapitel").control('data')" i see:
i believe the ampersand makes the different here.
It should be removed / escaped whatever...
until now my workaround is to clear the title in the onsubmit function to a default text:
So if i would add the field with ">" or "<" it dosnt work!
in Edit form if i call "fd.field("WikiKapitel").control('data')" i see:
Code: Select all
{
[functions]: ,
Id: "174",
WikiChapterTitle: "InputSystem <-> OutputSystem"
}
It should be removed / escaped whatever...
until now my workaround is to clear the title in the onsubmit function to a default text:
Code: Select all
var chapters = fd.field("WikiKapitel").value();
var data = [];
for(var i in chapters){
var item = {};
item.Id = chapters[i];
item[titleField] = "TmpTitle";
data.push(item);
}
fd.field("WikiKapitel").value(data);
ragesoft,
You can update multichoice lookup field with ID only, using the below code, so you will not use text value in your code.
You can update multichoice lookup field with ID only, using the below code, so you will not use text value in your code.
Code: Select all
var ID = 3;
// select element by ID:
fd.field('MultiLookup').control()._el().find('select:eq(0)').val(ID);
// add button click:
fd.field('MultiLookup').control()._el().find('button:eq(0)').click();
NO.
I don't usually need Code to set the field.
I'm only set the field in new-form because of a user action inside a wiki page.
The problem is the edit form.
If i don't use any code behind, i can't save the form, if it is initiated with a lookup-value that is defined as e.g. "Input <-> Output" or what ever...
I believe the problem comes with the lookup itself!
On init it try to escape the display value!?
You can easily reproduce the error:
Create "ListA"
Add items to it (just the title):
- "A <-> B"
- "C"
Create "ListB"
Add Column "LookupListA" pointing to ListA with "Title" as show field
Make it a csl with multi-select option
Add a new item to it:
- "Item 1" with LookupListA "A <-> B" selected
Save
Reopen "Item 1" for edit
Just try to save it => error
This is why i need the workaround here with code behind...
Greetings
I don't usually need Code to set the field.
I'm only set the field in new-form because of a user action inside a wiki page.
The problem is the edit form.
If i don't use any code behind, i can't save the form, if it is initiated with a lookup-value that is defined as e.g. "Input <-> Output" or what ever...
I believe the problem comes with the lookup itself!
On init it try to escape the display value!?
You can easily reproduce the error:
Create "ListA"
Add items to it (just the title):
- "A <-> B"
- "C"
Create "ListB"
Add Column "LookupListA" pointing to ListA with "Title" as show field
Make it a csl with multi-select option
Add a new item to it:
- "Item 1" with LookupListA "A <-> B" selected
Save
Reopen "Item 1" for edit
Just try to save it => error
This is why i need the workaround here with code behind...
Greetings
ragesoft,
I think the problem is in the "titleField" from which you are getting "InputSystem <-> OutputSystem" text for 'WikiKapitel' multichoice lookup filed.
What is the "titleField" field type? What do you see in the console when calling its value?
Please try to set 'WikiKapitel' multichoice lookup filed value in the New Form with the following code and see if you will get the error or not.
If it is Cross-site lookup field:
If it is Default lookup field:
You can check the field type in Forms Designer, field settings.
In case the error is still occurring, please provide more details to troubleshoot the issue.
- What Sharepoint version you are using? Is it Online or On-premises?
- What is the version of Forms Designer?
- Could you please share the whole code you are using to set 'WikiKapitel' value, clarify the field types and send the screenshots of the form.
I think the problem is in the "titleField" from which you are getting "InputSystem <-> OutputSystem" text for 'WikiKapitel' multichoice lookup filed.
What is the "titleField" field type? What do you see in the console when calling its value?
Please try to set 'WikiKapitel' multichoice lookup filed value in the New Form with the following code and see if you will get the error or not.
If it is Cross-site lookup field:
Code: Select all
fd.field('WikiKapitel').value([{Id: 174, Title: 'InputSystem <-> OutputSystem'}]);
Code: Select all
var ID = 174;
// select element by ID:
fd.field('test').control()._el().find('select:eq(0)').val(ID);
// add button click:
fd.field('test').control()._el().find('button:eq(0)').click();
In case the error is still occurring, please provide more details to troubleshoot the issue.
- What Sharepoint version you are using? Is it Online or On-premises?
- What is the version of Forms Designer?
- Could you please share the whole code you are using to set 'WikiKapitel' value, clarify the field types and send the screenshots of the form.
-
- Information
-
Who is online
Users browsing this forum: No registered users and 12 guests