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

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

Recommended Posts

Posted

I'm perplexed by the action of one of my scripts and I can't figure out the problem. Here's what I've got:

Set Error Capture (on)

If [isEmpty(field2)]

Copy [donor id FM]

Perform external script

End If

If [not IsEmpty(field2)]

show message (with choices for each of the 3 buttons)

End If

If [status(CurrentMessageChoice)=3]

copy [donor id FM]

Perform external script

End If

If [status(CurrentMessageChoice)=2]

Copy [donor id FM2]

perform external script

End If

****Note that everything works just fine up until this point when I run this part only. Now the trouble starts when the script continues:

If [status(CurrentMessageChoice)=1

Copy [donor id FM3]

perform external script

End If

When I add in this last message choice, for some reason the script goes haywire and jumps back to the starting page where the script begins, instead of going to the page which is instructed in the external acript. What am I missing here? It's weird that it only happens when the 3rd choice is added on.

Posted

If you want your external script to stay in the related file, you should add a Refresh [ bring to front ] at the end of the external script.

BTW, what exactly are you "Copying"

Posted

I'm not 100% sure of this (which means that I probably shouldn't speak grin.gif), but I think you will have to give the last control to the related db. For example the end if is the last step in the script, so it will go back to the main db.

But Ugo is right - a refresh window or go to layout script in the related db can be called at the absolute end of your main script.

Could someone verify?

Ken

Posted

Your script needs to be structured this way to work properly:

If [status(CurrentMessageChoice)=3]

.. copy [donor id FM]

.. Perform external script

Else

.. If [status(CurrentMessageChoice)=2]

.. .. Copy [donor id FM2]

.. .. perform external script

.. Else

.. .. Copy [donor id FM3]

.. .. perform external script

.. End If

End If

Also, if it happens to be the same external script, you can just put that step after the last If(), instead of putting it in there three times. Redundancy is bad bad bad.

BTW, experienced developers tend to shun copy/paste wherever possible, because e.g. it requires you to go to a particular field-layout-file, and it blows away the clipboard which may annoy your users. Instead, consider using Set Field (related::global field, donor id) to move your data around.

Posted

Good points Fitch. I was going to mention the script structure, but I got lazy.

Plus, I think that it should be more like this:

If [this is true]

do this

else

If [this is true]

Show Message

If [status(CurrentMessageChoice) = 1]

do this

and so on...

end if

end if

... as many end ifs as you need

Perform script [external] - this would be the refresh window or go to layout script in the related db.

But my scripts aren't the cleanest. But he said that it works (but does it really?? cool.gif)

Posted

As usual, Fitch nails it again. I just removed the redundant script commands (going to the external script in every If step) and now all is well. Thanks ever so much for your help.

(By the way, I already had the Refresh Window built into the tail end of the external script and that didn't make a difference.)

Now I have learned my redundancy lesson redundancy lesson.

This topic is 7728 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.