Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

Check Portal rows without the last blank row


This topic is 3708 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

Hello,

 

I would like to create a script when there is a field that is empty it's show a custom dialog.

The only thing i'm struggling with is the blank row the portal creates.

 

This the script i have:

 

Go To Portal Row [select; First}

Loop

If [isEmpty ( article::Number)]

Show Custom Dialog ["No Article";"No Article"]

      If [Get ( LastMessageChoice ) = 1]

      Exit Script[]

      End If

Else If [isEmpty ( Article::Description )]

Show Custom Dialog ["No Description";"No Description"]

     If [Get ( LastMessageChoice ) = 1]

      Exit Script[]

      End If

End If

Go to Portal Row [last]

End Loop

Posted

Make 2 relationships, one that is allowed to create records( in which you already have ) and one that is not

Use the one that is not allowed to create related records in this script.

Posted

The only thing i'm struggling with is the blank row the portal creates.

 

I'm not sure I understand the issue. Are you saying that the script creates a new related, empty record – or that there is an empty last row in the portal?

 

The former can't be true, because you cannot create a related record simply by looping through portal rows, and there is nothing in the script that sets a value into a related field (or any field, for that matter) – which would be a prerequisite for creating a related record in a portal.

 

The latter would be simply the spare row you see when you check “Allow creation of related records …” in the relationship definition. 

 

Make 2 relationships, one that is allowed to create records( in which you already have ) and one that is not

 

It would be better to write a proper script that uses Go to Portal Row [ next ], instead of last.

 

This will also adds the as-of-yet missing exit condition; though it wasn't mentioned by the OP, normally the script as shown should fall into an infinite loop.

 

Here's a (hopefully) better version, with an alternative ending for avoiding the spare portal row if there is added something to the script that does write a value.

# Set Variable [ $countRelated ; Count ( PortalTO::primaryKey ) )
# If ( not $countRelated ) ]
  # Exit Script
# End If
Go to Object [Object Name: "myPortal"]
Go to Portal Row [Select; First]
Loop
  If [// some condition]
    Show Custom Dialog ["Title"; "Message"]
    #1 = end, 2 = proceed
    If [Get ( LastMessageChoice ) = 1]
      Commit Records/Requests []
      Exit Script []
    End If
  Else If [// some other condition]
    Show Custom Dialog ["Title"; "Message"]
    #1 = end, 2 = proceed
    If [Get ( LastMessageChoice ) = 1]
      Commit Records/Requests []
      Exit Script []
    End If
  End If
  Go to Portal Row [Select; Next; Exit after last]
  # or: Exit Loop If ( Get ( ActivePortalRowNumber ) = $countRelated // for unfiltered portal only ]
  # Go to Portal Row [Select; Next]
End Loop
Commit Records/Requests []

This topic is 3708 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.