Jump to content
Server Maintenance This Week. ×

Performing a find on a portal


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

Recommended Posts

Would be most grateful if someone could help or point me in the right direction please.

 

I have a button on a portal whereby when clicked I would like it to copy data from a field on it (field named 'Beneficiary Allocations ID PK'), then paste it into a field on another portal (field named 'Beneficiary Allocations ID'), then perform a find to see if that value already exists.  Note: both portals are on the same layout.

 

I just keep getting the same message returned ""Aided funding type has already been used".  Here is my script: -

 

 

Go to Object [Object Name: “Aided Funding Portal”]

Go to Portal Row [select; Last]

Paste [select; Aided Expenditure Projects:: Beneficiary Allocations ID]

Enter Find Mode[]

Perform Find [Restore]

If[Get(FoundCount) ≠   0]

Show Custom Dialog [“Message Notice”; "Aided funding type has already been used"]

May put a delete portal row here but undecided…….

Else

Show Custom Dialog [“Message Notice”; "New aided funding added"]

End If

 

 

The specify find request behind my Perform Find is 'Aided Expenditure Projects:: Beneficiary Allocations ID: [!]

 

I hope I have explained it clearly

 

Cheers

Steve

Link to comment
Share on other sites

Two things. Your "enter find mode" step, as far as I can tell, should happen earlier. Another thing to note is that performing a find in a portal will find matches in the Master Record and not necessarily in the portal's related table. It would be better to go to a layout based on the portal's table and perform the find there.

Added: try to avoid copy/paste. There are many reasons to avoid this as you will find if you search the forums.

Link to comment
Share on other sites

I agree with everything Rick said.  Performing a find on the parent layout will result in ALL parents who match.  Instead, while on the parent layout, you can check your related records directly and see if Beneficiary Allocations ID is part of your related set.

 

Situation:  User has cursor in first portal and fires this script via button in portal.

If[ not IsEmpty ( FilterValues ( List ( Aided Expenditure Projects::Beneficiary Allocations ID ; *originalPortal::ID )) )]
Show Custom Dialog [“Message Notice”; "Aided funding type has already been used"]
Else
Set Variable [ $id ; *originalPortal::ID ]
Go to Object [Object Name: “Aided Funding Portal”]
Go to Portal Row [Select; Last]
Set Field [ Aided Funding Portal::Beneficiary Allocations ID ; $id ]
... insert here Go To Field [ data-entry field ] ... if User needs to continue data-entry
Show Custom Dialog [“Message Notice”; "New aided funding added"]
End If

This is a bit rough since I do not understand the User process.  Does the User continue to fill in information in the second portal?  Also notice that I did not know the name of the first portal so change it to what you need.

 

This script is based upon these facts and that 'allow creation' has been turned on in the relationship.  Otherwise you will need to go to the other table behind a Freeze Window (as Rick is suggesting) and add the new record there.  Let me know how this may need to be adjusted to fit your needs.  

 

Edited:  I added the line which begins with ... insert and portion in blue.

Edited by LaRetta
Link to comment
Share on other sites

to see if that value already exists. 

 

You should really explain what this is about. It's rarely necessary to perform a find in order to see if a value already exists. It's also not clear where this value should exist or not. If it's just among the child records of the current parent record, you could check that easily by looking at List ( Childtable::Valuefield ). Perhaps all you need here is some validation rule.

Link to comment
Share on other sites

Thank-you all for your posts and suggestions / help.

 

LaRetta, I tried your script and can't get the first line to work when writing it, keeps saying there are too few parameters in this function.

As asked, let me try and explain further what this is about. Please see attached snap-shot of my layout.

 

  • The portal with the heading above it 'Available (Aided) Funding Sources' is named 'Funding Available Portal'.  This is where I am trying to copy the data from. 

 

  • The portal with the heading above it 'Add Aided Funding' is named 'Aided Funding Portal'.  This is where I am trying to paste the data to and then do a check on this portal also to see if that funding type already exists.

You will see on my attached snap-shot that B-355 LCVAP has already been used so if the user Clicks the 'Use' button to try and use this funding type again, it will stop them.

 

I hope I have tried to explain this a bit better for you and it now makes sense what I am trying to do.

 

Cheers

Steve

Layout Snapshot.pdf

Link to comment
Share on other sites

Hi,

 

Comment - Post 355429 is exactly what i'm trying to achieve, unfortunately I can't get it to work for me but will keep trying.

 

LaRetta, I think I now understand your script but it just keeps returning the message "Aided funding type has already been added": -

 

If the 1st line of the script lists the full list of ID numbers from the first portal, in my case from my attached screen shot B-355, B-356.  Then filters the results based on the ID numbers in the 2nd portal, this being B-355.  Then isn't it always going to evaluate as not empty regardless of which record i'm in when I click the button?

 

Sorry, I have been trying all day to understand this and get it to work but with no luck.

 

Regards

Steve

Link to comment
Share on other sites

Hi,

 

Comment - Post 355429 is exactly what i'm trying to achieve, unfortunately I can't get it to work for me but will keep trying.

 

That is the best approach, Steve.

 

 

LaRetta, I think I now understand your script but it just keeps returning the message "Aided funding type has already been added": -

 

Well, I left off a parenthesis (typed manually from iPad) but also I mis-interpreted the portal names; as I said, it was a bit rough and would probably need to be tweaked.

 

However, following Comment's direction is always the best choice so I suggest you stick with his link.   :laugh2:

When you say you can't get it to work for you, it is best to tell us what/how is the spot where it fails and even provide screen shot in layout mode or of your graph.  I have not yet checked out the links referenced but his solutions will work if replicated correctly.

 

And if not, we are always here.

Link to comment
Share on other sites

Hi LaRetta,

 

OK, thank you for your reply.  I'm going to work again now on Comments direction, determined to crack it!! 

 

Thank you both for your help and time to date and pointing me in the right direction, will let you know how I get on :laugh2:

 

Steve

Link to comment
Share on other sites

It might be helpful to describe in a straightforward way what you are actually trying to accomplish.

 

Rather than the technology or script for accomplishing it.

 

My take:

For a given project, you have a goal for total funding.

You have a list of funding sources and amounts already selected for the project.

You have a list of all available funding sources.

 

You want to be able to add funding sources to the project; but not select a source that is ALREADY associated with the project.

 

Perhaps, when selecting the funding sources, the list of available sources should not even display the ones that have already been selected.

 

Or perhaps, it should display all sources but (1) give some kind of visual feedback that lets you see that this source is already linked to the project AND (2) not allow you to add this source to the project if the source is already linked to the project.

 

In any case it does not look like any find operations are necessary.

  • Like 1
Link to comment
Share on other sites

Bruce, thank you for the idea / suggestion.  I will look into it to see if that is a more suitable way but I have solved it for the time being using LaRetta's original script.

 

Comment, I have played around for a good for hours trying to get one of your examples your provided to work but with no luck.  It's a great example but I have many many tables, joins etc and struggling to configure it for my development.  I'm sure if you had a copy of my file you would quickly adapt it to work but i'm still learning.

 

LaRetta, I have simply created a global field for my second portal and tried this script and it works a treat: -

Copy[Select; BeneficiaryAllocationsforProjects::Beneficiary Allocations ID PK]
Go to Object [Object Name: “Aided Funding Portal”]
Paste[Select; Aided Expenditure Projects::Global Check Field]
If[ not IsEmpty ( FilterValues ( List ( Aided Expenditure Projects::Beneficiary Allocations ID) ; Aided Expenditure Projects::Global Check Field)))]
Show Custom Dialog [“Message Notice”; "Aided funding type has already been used"]
Else
Copy[Select; Aided Expenditure Projects::Global Check Field]
Go to Portal Row [Select; Last]
Paste[Select; Aided Expenditure Projects::Beneficiary Allocations ID]
Show Custom Dialog [“Message Notice”; "New aided funding added"]
End If

I know it has been recommended not to use copy/paste etc.  But if the above works perfectly and saves me duplicating tables in the graph, creating new joins etc is it that wrong to use the above script.

 

Cheers

Steve

Link to comment
Share on other sites

It's not that wrong to use the above script but it IS wrong to use copy/paste when Set Field[] does the exact same thing with the added protection that it works even if the field is not on the layout.  Also copy/paste destroys the User clipboard and they might have had other work on their clipboard and you just trashed it.  :-/

 

And it does not mean any more complexity in the graph or anything ... not sure why you would think that; if anything I said implied it then I was unclear.  As for whether it is the best method, without seeing your file or working through the details further, it is difficult to say; I still do not have a completely-clear picture.  But if Comment responded on this thread then that means I did not provide the perfect solution in his mind and, for me, it would GREATLY influence my decision to say that my solution is NOT the best approach in this regard.

 

As you learn more in this business, you'll look back at your work and wonder what you were thinking.  I've gone back to solutions written when new and I hope nobody ever sees them, LOL.  In truth, if it were me, I'd stick it out.  But if your graph is a mess, and if it works after thoroughly testing, then maybe we should call it a day.   

 

Oh, and at the end of that script, I suggest clearing the global and yes, using Set Field[].   :yep:

 

corrected typos and added:

 

About blue portion above:  At some future date, you may forget and remove a field from the layout and you'll then break your script.  There are a few times copy/paste MUST be used but unless it is, don't use it.

Edited by LaRetta
Link to comment
Share on other sites

Understood!  I shall change to use SetField[] and clear the global at the end of the script.

 

I will save a copy of my file and work on Comments solution also to get it working.

 

Thank you again, I am very appreciative of everybody's help, comments and advice.

 

Steve :laugh2:

Link to comment
Share on other sites

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