Skip to Content
avatar image
Former Member

Modal form example

Hi ,

I am newbie in SAP B1 9.2 . I need to use a form as modal form. I will use it in a matrix to choose data for a cell. When user clicks to a cell , a modal form will be opened. Then user will choose data from that modal form and press "OK" button. After pressing "OK" button the modal form will be closed and the application will continue.

Too many users say "you can use this method for modal forms:

public Form LoadForm(string fileName, string formType, BoFormModality modal = BoFormModality.fm_None)
{
 string contents = ReadFileContents(fileName);
 string uniqueId = GenerateUniqueId();
 
 var formDefinition = application.Create<FormCreationParams>(BoCreatableObjectType.cot_FormCreationParams);
 formDefinition.XmlData = contents;
 formDefinition.UniqueID = uniqueId;
 formDefinition.FormType = formType;
 formDefinition.Modality = modal;
 
 return application.Forms.AddEx(formDefinition);
}<br>

But, how can i use it? Where should i use it ?Can someone give me a full example?

Thank you.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Dec 14, 2016 at 08:23 AM

    Hi Huseyin,

    You'll have to catch the event GetFocus of the cell and then open your form.

    I'd recommend that you read through the SDK Help Center file and have a look at the samples in the SDK directory, usually:

    C:\Program Files (x86)\SAP\SAP Business One SDK\Samples

    Start with: C:\Program Files (x86)\SAP\SAP Business One SDK\Samples\COM UI\CSharp\02.CatchingEvents

    Note that the example above is a demonstration of how to use the property Modality. You can't copy and paste it into your code without any changes and hope it works (you shouldn't do that with any code from the web).

    Try it out and see how it fits into your code, try to understand what it's doing, then if you are stuck somewhere, come back and ask your questions and we will do our best to help you.

    Pedro Magueija

    LinkedIn | Twitter | Blog

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 14, 2016 at 08:57 AM

    Thank you for your answer.

    But, I have already checked cathing event examples. I can open a form already. I just want to open as modal. There is not enough documentation or example about this subject. This subject ( modal form ) is one of the basic needs to application developments. I asked due to this.

    Thanks



    Add comment
    10|10000 characters needed characters exceeded

  • Dec 14, 2016 at 10:26 AM

    Hi Huseyin,

    I understand. Note that in SAP Business One "modal forms" were notoriously hard to implement, until SAP created this feature.

    If you can already open a form then it is very straightforward to make it modal. As in the above sample use the formDefinition.Modality property or in your XML in the form tag add the modality="1".

    Pedro Magueija

    LinkedIn | Twitter | Blog

    Add comment
    10|10000 characters needed characters exceeded