Skip to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Autofill portal rows script

Featured Replies

I am creating a timesheet db for work. I have a start date field and an end date field I would like to create a script that when start date and end date are entered portal rows will populate the dates from the start to end date. I can do this setting fields I am a beginning to scripting any help would be appreciated ......Thx Ljr

Try:

Set Variable[$startDate; StartDateField]
Set Variable[$theDate; $startDate]
Set Variable[$endDate; EndDateField]
Freeze Window
Go to Layout ["SomeLayout"; YourPortalTO] 
# this could be any layout based on the TO that the portal relationship points to.
Loop
   New Record/Request
   Set Field[DateField; $theDate]
   Set Variable[$theDate; $theDate + 1]
   Exit Loop If[ $theDate > $endDate]
End Loop
Go to Layout[Original Layout]
  • Author

Thx I will give this a try and let you know how it turns out.....thx again

Hey Doug,

 

why declare a variable you never use?  :grad:  :laugh:

 

Set Variable[$startDate; StartDateField]
Set Variable[$theDate; $startDate]
Set Variable[$endDate; EndDateField]
Freeze Window
Go to Layout ["SomeLayout"; YourPortalTO] 
# this could be any layout based on the TO that the portal relationship points to.
Loop
   New Record/Request
   Set Field[DateField; $theDate $startDate + $i ]
   Set Variable[$i ; $theDate $i + 1]
   Exit Loop If[ $theDate $startDate + $i > $endDate]
End Loop
Go to Layout[Original Layout]
 
<CODE> doesn't support strike-through …
  • Author

Tried this script all that it is doing is adding the end date into the first first portal row, creating a new record and dumping the data

Tried this script all that it is doing is adding the end date into the first first portal row, creating a new record and dumping the data

 

This script is not supposed to use a portal; it's supposed to go to a layout of the table occurrence the portal points at, create new records, then return. … but we've forgotten to tell you that you should carry a primary key with you make those records related to whatever record you're on in the current layout; otherwise there'd be a bunch of records orphaned directly after birth …  :cry:

 

OK, you don't need to worry about that if you use a portal.

 

Make sure the relationship of the portal allows creation of related records, give your portal an object name (Inspector palette, Position tab) and try …

Set Variable [ $begin; LayoutTO::StartDateField ]
Set Variable [ $end; LayoutTO::EndDateField]
Set Variable ( $existing ; List ( PortalTO::DateField ) ]
Freeze Window
Go to Object [ yourPortalName ] 
Go To Portal Row [ last ]
Loop
   Set Variable [ $cur ; $begin + $i ]
   If [ IsEmpty ( FilterValues ( $existing ; $cur ) ) ]
     Set Field [ PortalTO::DateField ; $cur ]
     Go to Portal Row [ next ]
   End If
   Set Variable[ $i ; $i + 1]
   Exit Loop If [ $begin + $i > $end]
End Loop
Commit Record/Request
This version with a bit of duplicate-preventing code thrown in.
  • Author

thankyou i will give this a go, i really appreciate you taking the time and explaining this to me.....thx again

 

why declare a variable you never use?  :grad:  :laugh:

 

Well….Ummm….Errr……Uhhhh…..it seemed like a good idea at the time. :Whistle:

otherwise there'd be a bunch of records orphaned directly after birth …  :cry:

 

ROTFLMAO

 

Thanks for my daily laugh.

Well….Ummm….Errr……Uhhhh…..it seemed like a good idea at the time. :Whistle:

 

Don't I know that feeling …  :ermm:

Thanks for my daily laugh.

 

As always, glad to be of service.  :cool:

This script is not supposed to use a portal; it's supposed to go to a layout of the table occurrence the portal points at, create new records, then return. … but we've forgotten to tell you that you should carry a primary key with you make those records related to whatever record you're on in the current layout; otherwise there'd be a bunch of records orphaned directly after birth …  :cry:

 

OK, you don't need to worry about that if you use a portal.

 

Make sure the relationship of the portal allows creation of related records, give your portal an object name (Inspector palette, Position tab) and try …

Set Variable [ $begin; LayoutTO::StartDateField ]
Set Variable [ $end; LayoutTO::EndDateField]
Set Variable ( $existing ; List ( PortalTO::DateField ) ]
Freeze Window
Go to Object [ yourPortalName ] 
Go To Portal Row [ last ]
Loop
   Set Variable [ $cur ; $begin + $i ]
   If [ IsEmpty ( FilterValues ( $existing ; $cur ) ) ]
     Set Field [ PortalTO::DateField ; $cur ]
     Go to Portal Row [ next ]
   End If
   Set Variable[ $i ; $i + 1]
   Exit Loop If [ $begin + $i > $end]
End Loop
Commit Record/Request
This version with a bit of duplicate-preventing code thrown in.

Eos, where is the variable "$i" originally declared?

Rick.

It is not originally declared.

That's all the rage.

 

Since it is not declared, nothing +1 results in 1 the first time through.

 

I prefer to explicitly declare it, which can be helpful when using debugger to troubleshoot a script.

Bruce,

Good to know!

Thanks,

Rick.

Just as an added caution ... whenever possible, it is better to go to the other layout behind a Freeze Window[] to create your records rather than counting on the portal.  Sometime in the future, you may decide to replace the portal or remove it completely which will break your script.  You can put developer notes off screen to the right pointing out any hidden elements and this would be good to mention there.  :-)

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.