on 2014 Nov 06 10:44 AM
Hello Discussion Group,
I want to open a new form and I have a problem to get a reference on the new form. First I tried something like this:
Forms.OpenFormByKey("4", null); | |
Form myForm = GetFormFromUID(Application.Forms.ActiveForm.UniqueID); |
But sometimes another form is on top an I got the wrong form. In the internet are tips like:
oForm=Forms.GetFormByTypeAndCount("4", 1);
I think the second parameter is the count of the forms of this type and my newly created form is the last one? But how will I get the form-count for this type?
Thanks
Martin
Hi Martin,
Do you really need the reference right after the OpenForm(...)? An alternative could be to catch the after form load event which contains in the arguments (ItemEvent pVal) the exact id of the opened form. You can then use Form.Item(pVal.FormUid) to get the correct form.
Best regards,
Pedro Magueija
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm using the CoreSuite AddIn, I'm accessing the API functions by rules. This would create several rules and I would have to connect them. This is not so easy
I can use GetFormByTypeAndCount("150", Count) in a loop to get access to all open ArticelBaseData Forms. The last Form is the one that I have opened. But how can I get the number of opend forms per formtype?
Hi Martin,
Well if you already have the form instance (of a certain type) you can call form.TypeCount and that returns an int with the number of open form instances.
Each SAP Business One form has a type, which is a unique ID for the form. For example, the type of the Purchase Order form is 142.
Each form can be open multiple times, and the application keeps a counter for each form type of the number of open instances. To get the number of forms open of the same type, use Form.TypeCount. Form objects pointing to different instances of the same type form have the same value in the TypeCount field.
To access a specific instance of a specific form type, use the Forms.GetForm method.
Best regards,
Pedro Magueija
Thanks for the hint
So the dirty (but save) workaround looks like this in Coresuite API translation:
' Open new CustomerOrder Form in ADD mode:
SwissAddonFramework.UI.Components.Form.OpenFormByKey("17", Nothing) | |
Dim oForm As SwissAddonFramework.UI.Components.Form = SwissAddonFramework.UI.Components.Form.GetFormFromType("139", 1) oForm = SwissAddonFramework.UI.Components.Form.GetFormFromType("139", oForm.TypeCount) | |
oForm.Mode = SwissAddonFramework.UI.Components.ModeComponent.FormModes.ADD |
hi.
i will agree with mr Edy what u said is correct.
if n number of forms are opened does not a matter.
u can use
oform = sbo_applicaiton.form.activeform
after than
if oform.uniqueid ="fom1" then
your logic
end if
if oform.uniqueid = "form2' the
yur logic
end if.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Martin,
But sometimes another form is on top an I got the wrong form.
If you open up a form and the form is successfully opened, your newly opened form should be the Application.Forms.ActiveForm.
I have never encounter another form is on top of the newly opened form.
Regards
Edy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
105 | |
8 | |
6 | |
6 | |
5 | |
5 | |
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.