XrmDefinitelyTyped icon indicating copy to clipboard operation
XrmDefinitelyTyped copied to clipboard

Field statecode not generated

Open akiraquenot opened this issue 4 years ago • 4 comments

I am currently migrating my TS files to use XDT. For some reason, the generation process does not manage fields which are placed in the footer of the form ('statecode' field in my case).

So the following line of code fails on build because "Object 'this.formContext.getAttribute("statecode")' is possibly 'undefined' (TS2532)": this.formContext.getAttribute("statecode").setValue(customentity_statecode.Inactive);

Is that a bug or is there any way to make it work?

Thank you in advance!

Environment

  • CRM/D365/CDS version: 9.1.0000.25849
  • Tool version: 5.4.1

akiraquenot avatar Dec 17 '20 19:12 akiraquenot

According to some random blogs you have to get it by going through the control, but that seems weird to me. Anyway getControl("footer_statecode").getAttribute() should work

magesoe avatar Dec 17 '20 19:12 magesoe

Thanks @magesoe for your answer, I tried this way too but same result, the control is not recognized and it displays the same error message...

In fact I have nothing concerning 'statecode' field in my generated form.d.ts

akiraquenot avatar Dec 17 '20 19:12 akiraquenot

Fields in the footer are read only so do not get included. Add the field as a hidden field to the main form.

On Thu, 17 Dec 2020 at 19:47, akiraquenot [email protected] wrote:

Thanks @magesoe https://github.com/magesoe for your answer, I tried this way too but same result, the control is not recognized and it displays the same error message...

In fact I have nothing concerning 'statecode' field in my generated form.d.ts

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/delegateas/XrmDefinitelyTyped/issues/198#issuecomment-747660973, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFNWEFIAKMJ5AFOYOBU5E63SVJN5HANCNFSM4VADV7OA .

DeanHolmes avatar Dec 17 '20 22:12 DeanHolmes

@DeanHolmes Thank you for the information.

It is sad that XDT cannot manage that... For now, I manually created the method getAttribute("statecode") in the generated file to make the rule work.

akiraquenot avatar Dec 18 '20 13:12 akiraquenot