-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RichApi.Error: InvalidRequest on setting up field value #4050
Comments
@ishanig11 Could you please provide your document and your complete gist? And I found there is some syntax errors in your code. There are some references of word js api as following. |
FieldRefresh.docx |
@ishanig11 Can you provide your screenshots of the error? |
Thanks for pointing this. I changed error line to k.result.text.replace(k.result.text, "New Value") |
@ishanig11 It should be |
Refer attached document. Here Hello Word is getting inserted. But you can see field values are not replace. |
@ishanig11 Can you describe the scenario that you use field? From the document, I think you just want to replace the title and the major_rev to other string. If so, maybe the content control will be more suitable. |
Uploading ReactWordPortFolio.zip… Kindly check and let me know in case of any questions. |
@yilin4 any update on this issue? |
@ishanig11 Sorry for responding late. I have tried the following statement to insertText to a Field, you can have a try. But it's for changing the first Field in a document, and you can modify it according to your need.
|
@yilin4 : I tried above approach but still no change in document Quik Parts field value. Refer below screenshot: |
@ishanig11 Sorry, I have tried it again, and found it just works in desktop. It has been put on our backlog<Bug#8727789> for internal track. We will keep track of this issue and let you know if there are any updates. |
@yilin4 : We are completely blocked due to this issue? Can you please talk with developer and find some workaround for now? This is blocker issue for us. Thanks in advance. |
@yilin4 : I tried above approach but it did not work in Desktop version also. And I got below error: |
@yilin4 : any update? As mentioned earlier, please provide some workaround as mentioned earlier. As this is blocker issue for us. Thanks in advance |
Any update? |
@ishanig11 Sorry to respond late. It can work on desktop, but the field's type can't be others. You can try to set the field type to addin and have a try again. |
We cant't use ContentControl in our document as we have older documents which are using Quik Parts. So need solution for Quik Parts refresh. |
@ishanig11 Now, the online Field Object can't support the function you need. Could you estimate the user base and the revenue from your new add-in? So, we can better escalate this case and priories it. |
@yilin4 : we have developed this feature and now will showcase these to our clients. As per our current surveys client will be interested in this feature. But right now I cant comment on user base and revenue. But definitely it will be good one. Can you atleast tell me workaround to automatically refresh DOCPROPERTY field types in Desktop version for now? |
@ishanig11 Can you tell me the specific field type that in your document that you want to refresh? |
I want to refresh docproperty fields. These are fields basically from info
custom properties tab of word document.
…On Thu, 22 Feb 2024, 19:28 yilin4, ***@***.***> wrote:
@ishanig11 <https://github.com/ishanig11> Can you tell me the specific
field type that in your document that you want to refresh?
—
Reply to this email directly, view it on GitHub
<#4050 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BFS576ZUZ4QNE2JVNH7ST3TYU5FIDAVCNFSM6AAAAABCJ56MBGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNJZGUYDKMRTGA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
@ishanig11 You can try this. It can work on desktop to refresh the docProperty field. |
@ishanig11 I record this, you can see it. It's the desktop version. Recording.2024-02-23.194129.mp4 |
It worked for desktop. Thank you. But need solution for online version also :) If you can provide some workaround for the same that would be really helpful. |
@ishanig11 Now, the online version only has 4 field type, so if your document has the docProperty field, the online Word can't recognize it. If you have this need, we would like to suggest you go to https://techcommunity.microsoft.com/t5/microsoft-365-developer-platform/idb-p/Microsoft365DeveloperPlatform to ask a new question. Feature requests on it are considered when we go through our planning process. |
@ishanig11 There are two properties in the content control named cannotEdit and cannotDelete, I think you can use these two properties to control the content control not to be edited or deleted by users. |
This issue has been automatically marked as stale because it is marked as needing author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. Thank you for your interest in Office Add-ins! |
2 similar comments
This issue has been automatically marked as stale because it is marked as needing author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. Thank you for your interest in Office Add-ins! |
This issue has been automatically marked as stale because it is marked as needing author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. Thank you for your interest in Office Add-ins! |
This issue has been closed due to inactivity. Please comment if you still need assistance and we'll re-open the issue. |
1 similar comment
This issue has been closed due to inactivity. Please comment if you still need assistance and we'll re-open the issue. |
I am using following code to set field values from Ms Word document
Word.run(async (context) => {
var customDocProps = context.document.properties.customProperties;
context.load(customDocProps);
return context.sync()
.then(function () {
// now load actual property
var filenameProp = customDocProps.getItemOrNullObject("PW", { matchPrefix: true });
context.load(filenameProp);
return context.sync()
.then(function () {
try{
var fields = context.document.body.fields.load("items");
fields.load(["code", "result"]);
return context.sync()
.then(function () {
if (fields.items.length > 0) {
fields.items.forEach((k,i)=> {
k.result.insertText(k.result.text, "Updated Field Value");
k.load(["code", "result"]);
const paragraph = context.document.body.insertParagraph("Hello World", Word.InsertLocation.start);
return context.sync().then(function () {
console.log("Updated Field");
});
});
}
});
} catch (error) {
console.log("Error: " + error);
}
});
});
await context.sync();
console.log("Items", customDocProps.items);
});
But this code returns following error message:
Uncaught (in promise) RichApi.Error: InvalidRequest
at new n (word-web-16.00.js:25:335398)
at o.processRequestExecutorResponseMessage (word-web-16.00.js:25:399844)
at word-web-16.00.js:25:397907
Your Environment
This is on Windows system.
Latest office js file from CDN
Expected behavior
Field value should get updated without any issue.
Current behavior
Getting Invalid request error
Steps to reproduce
The text was updated successfully, but these errors were encountered: