Button Not Showing in Portal

I am new to Servoy and have created a form containing a portal. I added a button to the portal to allow users to add new records. However, when I run the form, the button does not appear in the portal. The relationship does allow for the addition of records.

Can anyone tell me why this might be happening or if there is a better way of doing this?

Thanks,
Brenda

You have to first select the portal and than add a button, or else the button won’t be a part of the portal!

I did that. I just deleted the button and added it again to be sure, but it’s still not showing up.

weird! place the button at the right side of the portal. What happens?

Hi Brenda,

Within Servoy, you cannot add records directly via a portal.

If you have placed your button within the portal and there are no related records present then you will not see the button.

If you want to have a button to trigger the addition of a related record then that button must be on the main form.

Cheers
Harry

I have changed my form so that my button is now outside the portal. The code for the button is:

portal_MaintDetails.newRecord()

I have also tried:

elements.portal_MaintDetails.newRecord()

However, when I run the form and click the button, I receive the following error:

“Error while performing method with name null, id 4293.”

The “Details” on the error say:

““True” is not defined.”

Hi Brenda,

You are nearly there.

Change the method attavhed to the button to :

elements.portal_MaintDetails.newRecord(true);

If the relationship is set to allow creation of related records then this should work for you.

Cheers
Harry

Hi Harry,

I tried using both true and false as the parameter, as well as leaving the parameter value blank, but it gives the same error every time.

Brenda

Hi Brenda… it should work… just check for any “typo” in your command, keeping in mind that Servoy IS case sensitive. Maybe you can show us your complete method.

Brenda:
“True” is not defined.

if this message is right then you probably passed “True” (undefined variable) to the newRecord() instead of “true” (reserved word = true value)

Here is the complete method:

forms.Maintenance.portal_MaintDetails.newRecord(true);

I believe that should be :
forms.Maintenance.elements.portal_MaintDetails.newRecord(true);

Oh wait…this is a portal right ? Your portal element is named ‘portal_MaintDetails’ ??
Or is this the relationship?
You need to use the relationshipname.
Thus forms.Maintenance.yourRelationshipName.newRecord();
Also your relationship has to be set to allow creation of records.

I changed the method to refer to the relationship rather than the portal. I didn’t realize that I was supposed to use the relationship name. :oops: However, I am still getting the same error. I checked the relationship and it is set to allow creation of new records (i.e., in the Define Relation form, the “Allow creation of related records” check box is checked. My method is now as follows:

forms.Maintenance.fk_maintenance_assetinfo.newRecord(true);

Yes, that’s what I just did as well: use the relation name.

I created a new method, then from the editor in the Navigator tree I went:

Application–>Forms–>my_main_form–>relations–>master-table_to_detail-table

Then below I see all the available functions for this relation, one of them is “newRecord”. I double click it an the code gets inserted:

master-table_to_detail-table.newRecord([addToTop],[changeSelection])

I didn’t use any of the parameters, so just:

master-table_to_detail-table.newRecord();

This worked fine for me. Same for a button to delete a record in the detail portal.

Cheers,
Han.

Brenda,

What is the exact error you get now?

Well, there are a lot of ways in Servoy to add records… and … they all work!!!.. so we must be missing something real simple… Brenda, try adding records using the relation instead of the portal and let’s see what happens.

Tell us the exact error you receive.

I was getting the same error as before, but I now have it working. My method says:

fk_maintenance_assetinfo.newRecord()

The problem was that the OnAction property for my button must have gotten changed at some point to use a different method (shown below) and I didn’t realize it. :oops:

currentcontroller.newRecord(True)

Thanks for all the help!