on 06-30-2015 12:40 AM
Hi,
I'm receiving a compile error "Can't assign to read-only property" in an Excel VBA enabled workbook. The code in bold raises the compile time error.
The relevant code is:
Set oOrder = oCompany.GetBusinessObject(SAPbobsCOM.oOrders)
....
oOrder.Lines.Text = "some sample text"
Note that I can successfully update all fields on header and row level (including UDFs of type text and date) on a sales order and this is the only field that is giving problems. Additionally, this field can be updated via the UI. The field in SQL db is of type 'ntext'.
eg. oOrder.Lines.FreeText = "some sample text" works fine (100 char field, not of type ntext though).
I'm using 9.1 PL07 and SQL Server 2008 R2 SP3. This issue has also been reproduced on 8.82 (not sure of PL).
Is it fair to assume that the read-only property for this field has been incorrectly set in SAPbobsCOM ? Or do I have to use a different syntax for fields of type text?
Thank you.
Regards,
George
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Pedro,
I think we are talking about different Text() properties as there are at least 2 in the DI API reference. Please see below for the one I'm having an issue with. Also note that I can update this by the UI (via SAP client), as per my initial email, so that confirms it is read-write.
SAP Business One DI API 9.1 - Objects Reference (910.150) | |
Text Property | |
The text to be saved for display in marketing documents.
The field must contain at least one non-space character and must be a valid key string (i.e., it cannot contain *,{,},%,!,^,=,<,>,?,|).
Field name: Text
Visual Basic |
---|
|
Hi George,
The fact that you can update the field thru the FAT client doesn't mean this is a read-write property for the UI-API: so Pedro and you can both be correct on this one.
After checking, according to the doc (can be wrong) and DotPeek (cannot be wrong):
So Pedro was correct and I was not.
Regards,
Eric
Hi George,
Did I understand correctly that you want to use the Document_Lines.Text property? If that is the case then it is read-only. However I did find the documentation you posted for the PredefinedText object. I believe this is like template text to be added by B1 to the marketing document.
Best regards,
Pedro Magueija
Hi Pedro,
Thanks, you are correct.
I have found the entry under "Document_Lines Object Members" and it is quite clear there that it is read-only (except for the typo where it uses lowercase for the field as in "text" not "Text").
I just don't understand why we can't update this field via the DI, when we can via the fat client, and why SAP hasn't enabled this yet in the DI. Anyways, I have a workaround, so that mystery will have to remain for now.
Thanks once again.
Kind Regards,
George
Hi George,
Unfortunately it is the case with some "properties" being editable in the client and not via the API.
You can try to raise a ticket with support and tell them that you can update via the client and not the API and you see this as a "issue".
They might view it the same way and have it changed in the future.
If you do go ahead and do this, please let us know the reply.
Good luck.
Best regards,
Pedro Magueija
Hi Pedro,
I'm unfortunately not affiliated with or registered as a SAP Partner at the moment (I'm currently working as a freelancer), so there is no possibility of me registering a support ticket, otherwise I definitely would. I'd love to assist in improving the SDK incrementally!
All the best,
George Mamacos
Hi George,
Syntax is correct and not related to the field... I'm more suspecting a VBA issue.
Since you can update UDF, may you do a test by creating one UDF of type ntext and to try to update it thry a small VBA sample?
Regards,
Eric
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Eric,
Can you update this field in C# or any other language, other than VBA ?
Thanks for your suggestion, I was thinking along the same lines but I have already tried it when I stated in my initial email "(including UDFs of type text and date)" , with 'text' implying 'ntext'.
Thanks once again for taking an interest in this issue.
Kind Regards,
George
User | Count |
---|---|
106 | |
12 | |
11 | |
6 | |
5 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.