Normal Topic Cannot import records with Unique numbers (Read 1147 times)
obfusc88
Full Member
***
Offline


No personal text

Posts: 194
Joined: Dec 17th, 2005
Cannot import records with Unique numbers
Oct 23rd, 2017 at 6:56pm
Print Post Print Post  
How to turn off Unique/Required for elements with a command? 

Using Export/Import on records with two Unique, Mandatory fields.  If I import with field copied, get message cannot save as unique. If I import without field, I get cannot save without mandatory field.   

Subroutine flow is this:
1. Make sure there is only one record in Result Set.
2.  Export record A. (Order with line items on subform)
3.  Import export file from A and save as record B.
4.  Remove record A from record set.
5.  Modify some values on Record B including making new Unique values in those two elements.
6.  Loop thru subform lines to update new unique fields.

Note this an Order form with line items on subform.   The subform lines also have similar unique elements.

The import process is not saving the new record B, so I cannot proceed any further. I cannot go past Step 3, because of the error messages.

I thought as a solution I could disable Unique, do import, update new fields and then enable Unique again.  But cannot find such a command.  Does it exist?  Whree?  If not, any suggestions on how to solve this? 

  
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2480
Joined: Aug 20th, 2003
Re: Cannot import records with Unique numbers
Reply #1 - Oct 23rd, 2017 at 8:29pm
Print Post Print Post  
If you are requiring a value using a restriction, you can remove that restriction by using the following bit of code

Code
Select All
Attribute(ElementName, 38, "") 



Where ElementName is the name of the element.

-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: Cannot import records with Unique numbers
Reply #2 - Oct 23rd, 2017 at 9:35pm
Print Post Print Post  
Thanks Ray, that should do it.  And what is the attr value to reset it again?  Yes/True/1/??)
Attribute(ElementName, 38, ???)

Not at system now, but it looks like if I run @Attribute(ElementName) it will return the correct value, and that is what I will use.  Does that sound correct?
  
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2480
Joined: Aug 20th, 2003
Re: Cannot import records with Unique numbers
Reply #3 - Oct 24th, 2017 at 1:00pm
Print Post Print Post  
Attribute 38 is the restriction, so you'll want to set it back to whatever value you had it set to(Probably '!').

-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: Cannot import records with Unique numbers
Reply #4 - Oct 24th, 2017 at 3:45pm
Print Post Print Post  
Ok, I was able to get the different values for Restriction and Unique (Attribute of READ_ONLY)

Restricted = "!" and ""

ReadOnly values are:
No = "0"
Unique = "0"
Yes, grayed out =  "1"
Yes, not grayed out = "2"

I would have thought that four different states would have four different values.  Is it intentional that NO and UNIQUE both have the same value?  If I reset that attribute to 0 how does that make the element unique, it only makes it not ReadOnly.
  
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2480
Joined: Aug 20th, 2003
Re: Cannot import records with Unique numbers
Reply #5 - Oct 24th, 2017 at 3:51pm
Print Post Print Post  
You can not check but can change the Unique Attribute in Runtime using ReadOnly().

-Ray
« Last Edit: Oct 24th, 2017 at 5:08pm by Ray the Reaper »  

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: Cannot import records with Unique numbers
Reply #6 - Oct 24th, 2017 at 5:05pm
Print Post Print Post  
Thanks Ray, I found that out.  This is the code I was using:
Code
Select All
	// Turn off Mandatory and Unique to allow new record to be saved. Reset at end of process.
	Attribute(OrderNumber,28,"0")			// Turn off Unique
	Attribute(OrderNumber,38,"")			// Turn off Mandatory
	Attribute(Record,28,"0")			// Turn off Unique
	Attribute(Record,38,"")				// Turn off Mandatory

	FormAttribute("OrderLines","Record",38,"")	// Turn off Mandatory on subform for line items.
	// ==================
 



Mandatory seemed to be working, but not Unique.  I tried using values of "" and "3", with no success.

You said I cannot change it with the ReadOnly attribute, is there another way to do this? 

If not, can we get this capability added to the current list of attribute variables in a future release?


  
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2480
Joined: Aug 20th, 2003
Re: Cannot import records with Unique numbers
Reply #7 - Oct 24th, 2017 at 5:10pm
Print Post Print Post  
I mistyped earlier. It was supposed to say you can not check but you can change the Unique Attribute using ReadOnly(). Modified it to fix error. That's what I get for trying to juggle too many trains of thoughts at a time.

ReadOnly(ElementName, 0) Turns off Unique and all ReadOnly
ReadOnly(ElementName, 3) Turns on Unique

-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: Cannot import records with Unique numbers
Reply #8 - Oct 24th, 2017 at 7:20pm
Print Post Print Post  
Sounds good, will try that tonight.  Thanks.
  
Back to top
 
IP Logged
 
obfusc88
Full Member
***
Offline


No personal text

Posts: 194
Joined: Dec 17th, 2005
Re: Cannot import records with Unique numbers
Reply #9 - Oct 25th, 2017 at 1:47am
Print Post Print Post  
Worked as intended, thanks a lot Ray.

Code
Select All
// Turn off Mandatory and Unique to allow new record to be saved. Reset at end of process.
	Attribute(OrderNumber,38,"")			// Turn off Mandatory. "!" is ON.
	ReadOnly(OrderNumber, 0)			// Turn off Unique  "3" is ON
	Attribute(Record,38,"")				// Turn off Mandatory.  "!" is ON.
	ReadOnly(Record, 0)				// Turn off Unique  "3" is ON
	FormAttribute("OrderLines","Record",38,"")	// Turn off Mandatory on subform for line items.  "!" is ON.
	// ================== 



Inserted this code just befor the Export Routine.  Did the import, and got no errors.  Was able to make some changes to the new form, and ran code after that to reverse the settings back to original Unique and Mandatory values.
  
Back to top
 
IP Logged