Hello everyone,
I have a solution for the add_form_comp() issue that I am testing. From what I can tell the bug either inserts at the beginning or the end depending on what you do, so the workaround function basically figures out where you want it, removes everything in front of it, adds the new form, then add everything else back. It could cause slowness depending on your forms and how far down the list you are adding forms but it seems to be working for me so far, especially for ordinal numbers. Its kind of hard for me to test before and after current as I don't have many of those. I plan to put it in a userlib file and rename all of my functions, then before SP 10 is in production I will uncomment the second line and when we do the install until it is fixed I will just comment it out again. Any feedback would be appreciated if anyone sees a better way to do anything here.
EDIT: This was made for CPS, not tested at all in EMR but I think it will work
{fn ADD_FORM_COMP_FIX(folderpath,name,insert_position,OPEN,label){
//Use this until upgrade to SP 10, then comment out
//ADD_FORM_COMP(folderpath,name,insert_position,OPEN,label) return ""
//at beginning and at end work okay
//fix is for ordinal numbers and before and after current
local formList = getfield(Get_form_list(),"|","")
local temp
local CurForm
local ordNum = "0" //just a default to keep it from crashing if it doesn't find the correct page (page refresh bug)
//needed right now for testing before and after current
cond
case (TOUPPER(insert_position) == "AT_BEGINNING" or TOUPPER(insert_position) == "AT_END")
//works fine
ADD_FORM_COMP(folderpath,name,toupper(insert_position),OPEN,label)
return ""
case (TOUPPER(insert_position) == "BEFORE_CURRENT" or TOUPPER(insert_position) == "AFTER_CURRENT")
//use _FormData from mldef1 to determine current form location
CurForm = CurrentForm()
for i = 1,i < size(formList), i = i + 1 do
temp = getfield(formList[i],"^","")
if temp[2] == curForm then
if insert_position == "BEFORE_CURRENT" then
ordNum = str(i) //insert at current lcoation to bump the rest back
else
ordNum = str(i + 1)
endif
endif
endfor
//continue
else
//assume ordinal number
ordNum = insert_position
//continue
endcond
if val(ordNum)size(formList) then
ADD_FORM_COMP(folderpath,name,"AT_END",OPEN,label)
return ""
endif
//its somewhere in the middle,remove first few
for i = 1,i 0, i = i - 1 do
temp = getfield(formList[i],"^","")
ADD_FORM_COMP(temp[1],temp[2],"AT_BEGINNING","","")
endfor
// --Now using open in the new form add instead, this is causing problems
//if toupper(OPEN) == "OPEN" then
// Delay(500)
// OPEN_FORM_COMP(folderpath + "\\" + name ,"")
//endif
return ""
}
}
{fn Delay(var){
local cnt = 0
for i = 1, i<=var,i = i + 1 do
cnt= cnt + i
endfor
return ""
}
}
{fn CurrentForm(){
//GE bug with tracking forms (related to page close handlers) may make this inaccurate but its the best we can do
// get page ID, this will be contained in one form set
local hold = getrow("_formData",0,"FID")
//need to parse out and read FSID from notetext, get it here
local temp = find("document","notetext")
local tmp = ""
local FormID = ""
local CheckOut= 0
//start with first fid
while CheckOut 0 then
return find("_MasterFormSets","Name","FSID",FormID)
endif
if match(temp,"[MLI_FORM:")<1 then CheckOut = CheckOut + 1 endif
endwhile
return ""
}
}
Posted : September 1, 2015 3:02 am