AnsweredAssumed Answered

Help with a script.

Question asked by MarcMcCall on Mar 16, 2012
Latest reply on Mar 16, 2012 by philmodjunk

Title

Help with a script.

Post

Hey All,

 

I could use a little help with a script.  I have a SSN field with an on object modify bullet control script set on it.  When something is typed into the field it is sent to another field and stored, and a bullet replaces what is typed in the original field.  I need to import a bunch of data into the DB, but do not want to import it into the store field, and if I import it into the field with the script set on it it will not trigger the script, transfer the data and show the bullets.  I have tested using a setvariable setfield scripts on another script that uses that sends data to that field from a popup window, and it would not work right, I had to use the copy paste into the field and after the paste it places my cursor in the field at the end of the script and on validate it triggers the transfer and bullet script just fine.  So what I think I would like to do, is when I import the data set up an import field to temporarilly store the SSN number and after all the records are imported, run a copy paste script that will copy from the temp field and paste in the field with the script trigger set up on it to activate the bullets and tranfer the data.  unless someone has a better idea than this.  I particularly would like to do something like this, because admin access will be allowed viewing of the SSN store field and if the SSN number is wrong, the other field will not control the store field if the script wasnt used to move the data.  I didn't write the script, just adapted it to my field.  

Bellow is the script I have set to trigger on the field with this parrameter "GetFieldName(T01_ACCOUNTS::SSN_Store)"

 

  • Set Error Capture [ On ]
  • Allow User Abort [ Off ]
  • #BULLET CONTROL
  • #to run as an OnObjectModify event.
  • #Capture status values
  • Set Variable [ $tring; Value:Get(ActiveFieldContents) ]
  • Set Variable [ $bulletField; Value:GetFieldName(GetField(Get(ActiveFieldName))) ]
  • Set Variable [ $added; Value:Let([ Nt = Substitute($tring; "•"; ""); c1 = Left(Nt; 1); p1 = Position($tring; c1; 1; 1); cN = Right(Nt; 1); pN = Position($tring; cN; Length($tring); -1)]; If(p1; Middle($tring; p1; pN - p1 + 1)) ) ]
  • Set Variable [ $cursor; Value:Get(ActiveSelectionStart) ]
  • If [ IsEmpty($added) and Length($tring) < Length(GetField(Get(ScriptParameter))) ]
  • #delete text
  • Set Field By Name [ Get(ScriptParameter); Let( Source = GetField(Get(ScriptParameter)); Left(Source; $cursor - 1) & Right(Source; Length($tring) - $cursor + 1) ) ]
  • Else If [ IsEmpty($added) ]
  • #Reject bullets
  • Set Field By Name [ $bulletField; Let([ SLnth = Length(GetField(Get(ScriptParameter))); $over = Length($tring) - SLnth]; If(SLnth; Substitute(10^SLnth - 1; "9"; "•")) ) ]
  • Else
  • #Insert new text
  • Set Field By Name [ Get(ScriptParameter); Let( Source = GetField(Get(ScriptParameter)); Left(Source; $cursor - 1 - Length($added)) & $added & Right(Source; Length($tring) - $cursor + 1) ) ]
  • Set Field By Name [ $bulletField; Substitute(10^Length($tring) - 1; "9"; "•") ]
  • End If
  • Set Selection [ Start Position: $cursor - $over; End Position: $cursor - 1 - $over ]
  • ##

Outcomes