Jump to content

Generating records with a script and a portal


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

Recommended Posts

I have a portal that has '"create related records" disabled. This is to mitigate data-entry error on the part of the user.

So, I have a script that uses a counter and a loop to create the desired number of fields in the related database by calling an external script. This works rather well.

What I need to do is have each new field to be visible in the portal from the record that they are created from. I've been trying to do this by:

SetField("course_number", B):course_number")

But, it only works once, and in the second record created by the external script rather than the first.

Can anyone suggest how might I apply the "course_number" identifier so that the newly generated records will be visible in my portal?

Link to comment
Share on other sites

No doubt there are several methods to do this, but the one that comes to mind is to have a second relationship identical to the first one, except that you have the "allow creation" option turned on. You can then force the creation of new related records by executing a script that goes to a different layout with a portal based on this new relationship, and then do a Go to portal row [last]; then set the value of any field in the related file via this relationship.

Set field [gCounter, 1]

Go to Layout [WorkingLayout]

Loop

Link to comment
Share on other sites

Would it be possible to simply have a global field containing a calculated value that is the current "course_number" that could then be passed to the related database. I'm away from my work computer and haven't had a chance to try it yet.

I will have approximately 2500 fields created this way across five related databases so it important that I do this right.

Link to comment
Share on other sites

Yes you can set up a constant relationship "constantRelationship" between the two files so that you can get the value of global fields from the other file. Create a calculated field in each file with the formula "1" Then create a relationship based on these two fields. Then, any global in either file will be accessible in the other file. So you can set a global "course_number" to the course number in the first file and then execute the script in the other file that creates records and then sets the course number field in that file to the global value in the first file. Like this:

Set Field [ CourseNumber, constantRelationship::course_number]

Link to comment
Share on other sites

Just to clarify, any global is accessible from any other file through any relationship to that file, whether it be valid or not. And an invalid relationship can be much faster than a constant one, especially if the related file has several hundred/thousand records.

Link to comment
Share on other sites

This topic is 6533 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
 Share

×
×
  • Create New...

Important Information

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