Jump to content
Sign in to follow this  
angelleye

Why is this Set Field not working...???

Recommended Posts

I've got a table called InvoiceItems and another table called Scans. These tables are related by ScanID.

I'm trying to create a script that will set the Status field value in Scans from InvoiceItems. My script is as follows:

'find set of InvoiceItems records to loop through...this part works fine.

Loop

If[$RecordType = "Invoice"]

Set Field [invoiceItemsToScansByScanID::Status; "Sold"]

Else

Set Field [invoiceItemsToScansByScanID::Status; "Returned"]

End If

Go to Record/Request/Page [Next; Exit after last]

End Loop

When I set a static value for $RecordType and make it Invoice so it should set the status to Sold it seemingly works in Debug Scripts mode because it does go through that portion of the If/Then statement. However, when it's done the status field in my Scan record does not equal Sold. It's simply left as it was.

I double checked that the InvoiceItems table and the InvoiceItemsToScansByScanID tables both contain the same ScanID and that field is being used to relate those tables.

Why is not setting that field for me? Any information on this would be greatly appreciated. Thanks!

Share this post


Link to post
Share on other sites

Why $RecordType and not only InvoiceItems::RecordType ?

Share this post


Link to post
Share on other sites

The script originates from Invoices and RecordType is passed as a script paramater. That part is working fine. It even goes through the Set Field part when testing with debug scripts. It just doesn't actually change the value of that field for some reason.

Share this post


Link to post
Share on other sites

But that $RecordType is into a Loop and can't never change, so I'm sure that there is the error !

Share this post


Link to post
Share on other sites

Once it gets to this point it shouldn't change. When you click the button in Invoices that activates this script it includes in the script paramater a value that says "Invoice" or "Credit Memo". From that point all items on that invoice need to be set accordingly. So once it's gotten to invoice items it NEEDS to remain the same throughout the loop.

When I run debug mode it does hit the correct Set Field step and seemingly works just as it should. But then I go check that field in Scans and it isn't set to Sold.

Share this post


Link to post
Share on other sites

Here's a little bit more detailed explanation of what's going on here....

http://www.dealexpress.com/temp/fmproblem.html

Edited by Guest

Share this post


Link to post
Share on other sites

Hate to ask the obvious, but are you sure Status is of type Text?

Have you tried error trapping? Set Error Capture [On] and in your Data Viewer, create a Get(LastError) expression. Step through the script and Refresh the Data Viewer immediately after the Set Field step. Is there an error code?

Finally, a Looping Set Field is unnecessary. A Replace Field Contents would do the trick.

Share this post


Link to post
Share on other sites

Yes, I double checked and the data type for Scans::Status is indeed text.

I'll have to play with error trapping. I'm not sure what you mean by "in your Data Viewer." what is my data viewer?

As for the set field vs. replace field contents, i'm a little confused on how that works too. I've used Replace Field Contents manually a few times and it's a great tool. but in this case how would it get all of the items if there are multiple items on the invoice? The Scans table doesn't have InvoiceNumber in it. Those tables are only related by ScanID so if I use a GTRR with ScanID it'll only replace contents for that 1 single record wouldn't it..?? Am I not understanding how that works correctly..??

Share this post


Link to post
Share on other sites

I'm not sure what you mean by "in your Data Viewer." what is my data viewer?

You dont have Data Viewer because it is a feature of FM Advanced (which started 8+)

As for the set field vs. replace field contents, i'm a little confused on how that works too. I've used Replace Field Contents manually a few times and it's a great tool. but in this case how would it get all of the items if there are multiple items on the invoice? The Scans table doesn't have InvoiceNumber in it. Those tables are only related by ScanID so if I use a GTRR with ScanID it'll only replace contents for that 1 single record wouldn't it..?? Am I not understanding how that works correctly..??

I think I addressed this in your last post. If you have an invoice lineitems table which should be a join table of invoiceIDs and ScanIDs.

If you use a go to related record from the invoies that you want, it will display all the realted line items. Make sure you have the option checked to display only related records. Once you do that, you can use another GTRR to get to the related scan records. Make sure you have the option on to display only related records as well. However, there is yet another option that states 'Match all records in found set'. Check that and it will match all scan IDs realted to the found set of line items.

Share this post


Link to post
Share on other sites

Since you mentioned Debug Scripts, I assumed you had a Data Viewer. My apologies. Instead you'd set up a Global Text field on your layout (temporarily) and put two script steps immediately after your Set Field: another Set Field to your new Global with a value of Get(LastError) and Pause/Resume. You can then check to see what the Last Error was in your Global.

But now that I'm rereading the posts...How many Scans are there per Invoice? If more than one, then your Set Field from the 'parent' Invoice table will only affect the first record for that invoice.

Also, do you have proper permissions to edit those records?

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

×

Important Information

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