Normal Topic FormFfieldValue not working for Boolean element (Read 2036 times)
obfusc88
Full Member
***
Offline


No personal text

Posts: 194
Joined: Dec 17th, 2005
FormFfieldValue not working for Boolean element
Jul 9th, 2017 at 9:16pm
Print Post Print Post  
I am using FormFieldValue to copy a field from a SubForm (TAXABLE) to the Parent form(TRANSTAXABLE).  The routine does this for about ten elements.  They all work good except for the Boolean field.  No matter what the source value is (Y/N/null), the destination value ends up as NULL. 

The source field is a normal bound Boolean field.
The destination field is an unbound field, set to Boolean format.

When I do the reverse, and send the unbound Parent field to the bound element on the subform, it does work OK.  It only fails when trying to update the unbound boolean field.  All of the elements on the parent form are also unbound.  And all the elements on the subform are bound.
============================
Code
Select All
If SortNo <> 0 Then {
	FormFieldValue(sParentFormName, "TransSortNo",	0, SortNo)
	} Else {
	FormFieldValue(sParentFormName, "TransSortNo",	0, "")
	}
FormFieldValue(sParentFormName, "TransParentOrder", 0, ParentOrder)
// FormFieldValue(sParentFormName, "Record", 0, ParentRecord)
FormFieldValue(sParentFormName, "TransClass", 0, ItemClass)
FormFieldValue(sParentFormName, "TransAccount", 0, Account)
FormFieldValue(sParentFormName, "TransItem", 0, Item)
FormFieldValue(sParentFormName, "TransDescription", 0, Description)
FormFieldValue(sParentFormName, "TransTaxable", 0, Taxable)

If OrderQty <> 0 Then {
	FormFieldValue(sParentFormName, "TransOrderQty", 0, OrderQty)
	} Else {
	FormFieldValue(sParentFormName, "TransOrderQty", 0, "")
	}

If ShipQty <> 0 Then {
	FormFieldValue(sParentFormName, "TransShipQty", 0, ShipQty)
	} Else {
	FormFieldValue(sParentFormName, "TransShipQty", 0, "")
	}
//If BOQty <> 0
FormFieldValue(sParentFormName, "TransBOQty", 0, BOQty)
//Else
//	FormFieldValue(sParentFormName, "TransBOQty", 0, "")
If UnitPrice <> 0 Then {
	FormFieldValue(sParentFormName, "TransUnitPrice", 0, UnitPrice)
	} Else {
	FormFieldValue(sParentFormName, "TransUnitPrice", 0, "")
	}

If Discount <> 0 Then {
	FormFieldValue(sParentFormName, "TransDiscount", 0, Discount)
	} Else {
	FormFieldValue(sParentFormName, "TransDiscount", 0, "")
	}

If ExtPrice <> 0 Then {
	FormFieldValue(sParentFormName, "TransExtPrice", 0, ExtPrice)
	} Else {
	FormFieldValue(sParentFormName, "TransExtPrice", 0, "")
	}

If SalesTax <> 0 Then {
	FormFieldValue(sParentFormName, "TransSalesTax", 0, SalesTax)
	} Else {
	FormFieldValue(sParentFormName, "TransSalesTax", 0, "")
	}

// Recalculate Line Item Extended Price
mysubCalcLine()
 



Thanks to Carl for an old article he wrote that inspired this code for me.
  
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: FormFfieldValue not working for Boolean element
Reply #1 - Jul 10th, 2017 at 5:50pm
Print Post Print Post  
What type of element is TRANSTAXABLE? I just tried this with both an unbound Text Box and an unbound Check Box and was able to set the value of both from a subform with FormFieldValue().

Have you tried setting TRANSTAXABLE to a hardcoded value in code instead of the value of an element on your form? Does that work?

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
obfusc88
Full Member
***
Offline


No personal text

Posts: 194
Joined: Dec 17th, 2005
Re: FormFfieldValue not working for Boolean element
Reply #2 - Jul 11th, 2017 at 12:03am
Print Post Print Post  
TransTaxable Type is originally added to the form as a CheckBox, Bind element to "Unbound". Text format changed from System Settings Text to Unbound Boolean.  Shows as bound to Boolean

Maybe should have been added as a CheckBox, Bind element to New Boolean.  Then change Bound from TransTaxable to None.  Then removed the field TransTaxable?  Then it would be bound to Text Type like the other Transxxx elements.
  
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: FormFfieldValue not working for Boolean element
Reply #3 - Jul 11th, 2017 at 8:31pm
Print Post Print Post  
Hmm. That is the same way that I added the unbound check box here in testing. Have you tried setting it to a hardcoded value of 1?

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
obfusc88
Full Member
***
Offline


No personal text

Posts: 194
Joined: Dec 17th, 2005
Re: FormFfieldValue not working for Boolean element
Reply #4 - Jul 11th, 2017 at 9:53pm
Print Post Print Post  
Can't hard code to 1 since it varies.   Maybe solution is to get a variable for Taxable and put the variable into the FormFieldValue.
  
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: FormFfieldValue not working for Boolean element
Reply #5 - Jul 12th, 2017 at 12:57pm
Print Post Print Post  
I apologize if I was not clear. I meant as a test, if you hardcode it to set the value to 1, does it get set correctly?

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
obfusc88
Full Member
***
Offline


No personal text

Posts: 194
Joined: Dec 17th, 2005
Re: FormFfieldValue not working for Boolean element
Reply #6 - Jul 12th, 2017 at 3:14pm
Print Post Print Post  
Yes.  I used FormFieldValue("TransTaxable",1) and it did post correctly.
  
Back to top
 
IP Logged
 
obfusc88
Full Member
***
Offline


No personal text

Posts: 194
Joined: Dec 17th, 2005
Re: FormFfieldValue not working for Boolean element
Reply #7 - Jul 12th, 2017 at 5:26pm
Print Post Print Post  
I also see in the Property Viewer that the SubForm Taxable element has a format of "1 [20]" and the Parentform TransTaxable element has a format of "1[]".

Ahh, 1[] is System Boolean, and 1[20] is Custom Boolean 1/0.

Changed them both to Y[01], Custom Boolean Y/N.  Makes no difference.  Still does not post from SubForm to Parent Form. 

Changed Parent Form Element format to System Text vs Custom Boolean, and it appears to work.

So the destination has to be Text vs. Boolean for FormFieldValue to work when a Boolean element is the source?

At any point, this is fixed for me right now, but seems like there is an underlying issue here?
  
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: FormFfieldValue not working for Boolean element
Reply #8 - Jul 13th, 2017 at 1:22pm
Print Post Print Post  
obfusc88 wrote on Jul 12th, 2017 at 5:26pm:
So the destination has to be Text vs. Boolean for FormFieldValue to work when a Boolean element is the source?


In my testing here, I was able to post to both a text box and a check box that were both formatted as Boolean on the parent form. So I am thinking you have something else going on besides that.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged