I am building a PCF for a custom page and one of the controls is an input that allows a user to upload a file attachment to a column of datatype file.
I feel like there is more than one step in updating the database with the file content because the following does not work.
const fileString = {
slp_file: {
fileContent:
"PD94bWwgdmVyc2lvbj0iMS4wIiBzdGFuZGFsb25lPSJubyI/Pg0KPHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4NCiAgICA8cmVjdCB4PSIwIiB5PSIwIiB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHN0cm9rZT0iYmxhY2siIGZpbGw9InJlZCIgc3Ryb2tlLXdpZHRoPSIwIi8+DQo8L3N2Zz4=",
fileName: "Square_Red_16x16.svg",
fileSize: 215,
mimeType: "image/svg+xml",
},
};
const newRecord = Xrm.WebApi.updateRecord(this.resultItem.logicalName, this.id, fileString).then(
(r) => r,
(e) => console.log(e),
);
};
I keep getting the following error.
1: An error occurred while validating input parameters: Microsoft.OData.ODataException: An unexpected 'StartObject' node was found for property named 'slp_file' when reading from the JSON reader. A 'PrimitiveValue' node was expected.
Is there a table like fileattachment to create the file first and then associate the link to this record to the actual field in my table?
Does anyone know what steps I should take to save the selected file to the database to a field that has datatype or "File" or "Image".