324. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 5/9/2017 12:03:03 PM Eastern Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

324.1 Files compared

# Location File Last Modified
1 Tue May 9 16:03:03 2017 UTC
2 OSCIF_HEC_v1.4_Sprint23_build4_Apr_2017.zip\CRM_solutions\Managed\North52BPA_1_0_0_506_managed_2013_2015_2016..zip\WebResources north52_javascriptformulaeditor4846A6E9-0E5A-E411-8363-00155DF5B00D Mon Sep 19 18:20:18 2016 UTC

324.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 0 0
Changed 0 0
Inserted 1 3
Removed 0 0

324.3 Comparison options

Whitespace
Character case Differences in character case are significant
Line endings Differences in line endings (CR and LF characters) are ignored
CR/LF characters Not shown in the comparison detail

324.4 Active regular expressions

No regular expressions were active.

324.5 Comparison detail

        1   "undefined "==typeof  North52&&( North52={} ),"undefin ed"==typeo f North52. FormulaEdi tor&&(Nort h52.Formul aEditor={} ),North52. FormulaEdi tor.GetWor dsBetweenC urlies=fun ction(a){f or(var d,b =[],c=/{([ ^}]+)}/g;d =c.exec(a) ;)b.push(d [1]);retur n b},North 52.Formula Editor.Loa dSourceTre e=function (){6!=pare nt.Xrm.Pag e.ui.getFo rmType()&& (setTimeou t(function (){North52 .FormulaEd itor.LoadP rocesses() },1e3),set Timeout(fu nction(){N orth52.For mulaEditor .LoadxCach e()},1500) ,setTimeou t(function (){North52 .FormulaEd itor.LoadF orms()},2e 3))},North 52.Formula Editor.Ope nWizard=fu nction(){$ ("#dialogF unctionWiz ard").wijd ialog("ope n")},North 52.Formula Editor.Set DefaultNam e=function (){var a=$ ("#sourcee ntity").va l();if(1== parent.Xrm .Page.ui.g etFormType ()){var b= "EntityLis t52"+paren t.Xrm.Page .context.g etOrgUniqu eName(),c= JSON.parse (localStor age.getIte m(b));a=No rth52.Sour ceEntity.G etEntityDi splayName( a,c),a=a+"  - "+$("#f ormulaType  option:se lected").t ext(),a=a+ " - "+new  Date,paren t.Xrm.Page .data.enti ty.attribu tes.get("n orth52_nam e").setVal ue(a),$("# formulaNam e").val(a) }else a="" !=$("#form ulaName"). val()?$("# formulaNam e").val(): parent.Xrm .Page.data .entity.at tributes.g et("north5 2_name").g etValue(); return a}, North52.Fo rmulaEdito r.ClearFun ctions=fun ction(){$( "#txtFind" ).val(""), North52.Fo rmulaEdito r.SearchCl ear("#tree functions" ),$("#txtF ind").focu s()},North 52.Formula Editor.Cle arSource=f unction(){ $("#txtFin dSource"). val(""),No rth52.Form ulaEditor. SearchClea r("#treeso urce"),Nor th52.Formu laEditor.S earchClear ("#treerel ated"),Nor th52.Formu laEditor.S earchClear ("#treerel atednn"),N orth52.For mulaEditor .SearchCle ar("#treef orms"),Nor th52.Formu laEditor.S earchClear ("#treepro cesses"),N orth52.For mulaEditor .SearchCle ar("#treex cache"),No rth52.Form ulaEditor. SearchClea r("#treeca lculations "),North52 .FormulaEd itor.Searc hClear("#t reedecisio ncalculati ons"),Nort h52.Formul aEditor.Se archClear( "#treeacti ons"),$("# txtFindSou rce").focu s()},North 52.Formula Editor.Tab Selection= function() {1==parent .Xrm.Page. ui.getForm Type()?$(" #tabsalpha ").wijtabs ("select", 0):($("#ta bsalpha"). wijtabs("s elect",1), $("#accord ion").wija ccordion(" activate", 0),$("#acc ordion").w ijaccordio n("activat e",1))},No rth52.Form ulaEditor. RegisterSe tFormulaTy peVisibili ty=functio n(){$("#fo rmulaType  option[val ue='217890 005']").at tr("disabl ed",!1),$( "#formulaT ype option [value='21 7890000']" ).attr("di sabled",!1 ),$("#form ulaType op tion[value ='21789001 4']").attr ("disabled ",!1),$("# formulaTyp e option[v alue='2178 90015']"). attr("disa bled",!1), $("#formul aType opti on[value=' 217890016' ]").attr(" disabled", !1),$("#fo rmulaType  option[val ue='217890 017']").at tr("disabl ed",!1),$( "#formulaT ype option [value='21 7890018']" ).attr("di sabled",!1 ),$("#form ulaType op tion[value ='21789001 9']").attr ("disabled ",!1),$("# formulaTyp e option[v alue='2178 90013']"). attr("disa bled",!1), $("#formul aType opti on[value=' 217890003' ]").attr(" disabled", !1),$("#fo rmulaType  option[val ue='217890 001']").at tr("disabl ed",!1),$( "#formulaT ype option [value='21 7890004']" ).attr("di sabled",!1 ),21789000 2==$("#for mulaMode") .val()?($( "#formulaT ype option [value='21 7890014']" ).attr("di sabled",!0 ),$("#form ulaType op tion[value ='21789001 5']").attr ("disabled ",!0),$("# formulaTyp e option[v alue='2178 90003']"). attr("disa bled",!0), $("#formul aType opti on[value=' 217890004' ]").attr(" disabled", !0)):21789 0001==$("# formulaMod e").val()& &($("#form ulaType op tion[value ='21789000 5']").attr ("disabled ",!0),$("# formulaTyp e option[v alue='2178 90017']"). attr("disa bled",!0), $("#formul aType opti on[value=' 217890018' ]").attr(" disabled", !0),$("#fo rmulaType  option[val ue='217890 019']").at tr("disabl ed",!0),$( "#formulaT ype option [value='21 7890016']" ).attr("di sabled",!0 ),$("#form ulaType op tion[value ='21789001 3']").attr ("disabled ",!0),$("# formulaTyp e option[v alue='2178 90001']"). attr("disa bled",!0), $("#formul aType opti on[value=' 217890000' ]").attr(" disabled", !0))},Nort h52.Formul aEditor.Ad dFetchXML= function() {var a={}; 1==parent. Xrm.Page.u i.getFormT ype()?Xrm. Utility.al ertDialog( "You must  save the F ormula rec ord before  creating  any fetch- xml querie s."):(a.no rth52_form ula_north5 2_formulad etail_id=p arent.Xrm. Page.data. entity.get Id(),a.nor th52_formu la_north52 _formulade tail_idnam e=parent.X rm.Page.ge tAttribute ("north52_ name").get Value(),Xr m.Utility. openEntity Form("nort h52_formul adetail",n ull,a))},N orth52.For mulaEditor .RegisterF ieldSyncAu toNumber=f unction(){ parent.Xrm .Page.data .entity.at tributes.g et("north5 2_autonumb ervalue"). setValue(p arseInt($( "#formulaA utoNumber" ).val()))} ,North52.F ormulaEdit or.Registe rFieldSync DisplayFor mat=functi on(){paren t.Xrm.Page .data.enti ty.attribu tes.get("n orth52_dis playformat ").setValu e($("#form ulaDisplay Format").v al())},Nor th52.Formu laEditor.R egisterMod eChange=fu nction(){N orth52.For mulaEditor .RegisterS ync(),2178 90002==par ent.Xrm.Pa ge.data.en tity.attri butes.get( "north52_m ode").getV alue()&&pa rent.Xrm.P age.data.e ntity.attr ibutes.get ("north52_ sourceenti typroperty clientside ").setValu e(""),2178 90001==par ent.Xrm.Pa ge.data.en tity.attri butes.get( "north52_m ode").getV alue()&&pa rent.Xrm.P age.data.e ntity.attr ibutes.get ("north52_ sourceenti typroperty ").setValu e(""),Nort h52.Formul aEditor.Sh owHideClie ntSide();v ar a=paren t.Xrm.Page .data.enti ty.attribu tes.get("n orth52_sou rceentityn ame").getV alue();Nor th52.Metad ataPropert y.Load(a," north52_so urceentity property", "true",!1) },North52. FormulaEdi tor.Regist erSync=fun ction(){pa rent.Xrm.P age.data.e ntity.attr ibutes.get ("north52_ formulades cription") .setValue( $(".CodeMi rror")[0]. CodeMirror .getValue( )),parent. Xrm.Page.d ata.entity .attribute s.get("nor th52_name" ).setValue (North52.F ormulaEdit or.SetDefa ultName()) ,parent.Xr m.Page.dat a.entity.a ttributes. get("north 52_formula type").set Value($("# formulaTyp e").val()) ,parent.Xr m.Page.dat a.entity.a ttributes. get("north 52_mode"). setValue($ ("#formula Mode").val ()),parent .Xrm.Page. data.entit y.attribut es.get("no rth52_pipe linestage" ).setValue ($("#formu laPipeline Stage").va l()),paren t.Xrm.Page .data.enti ty.attribu tes.get("n orth52_pip elineevent ").setValu e($("#form ulaEvent") .val()),pa rent.Xrm.P age.data.e ntity.attr ibutes.get ("north52_ displayfor mat").setV alue($("#f ormulaDisp layFormat" ).val()),p arent.Xrm. Page.data. entity.att ributes.ge t("north52 _tracingle vel").setV alue($("#f ormulaTrac eLevel").v al()),pare nt.Xrm.Pag e.data.ent ity.attrib utes.get(" north52_ca tegory").s etValue($( "#formulaC ategory"). val()),par ent.Xrm.Pa ge.data.en tity.attri butes.get( "north52_s ubcategory ").setValu e($("#form ulaSubCate gory").val ()),null!= $("#formul aExecution Order").va l()&&""!=$ ("#formula ExecutionO rder").val ()&&parent .Xrm.Page. data.entit y.attribut es.get("no rth52_exec utionorder ").setValu e(parseInt ($("#formu laExecutio nOrder").v al())),nul l!=$("#for mulaAutoNu mber").val ()&&""!=$( "#formulaA utoNumber" ).val()&&p arent.Xrm. Page.data. entity.att ributes.ge t("north52 _autonumbe rvalue").s etValue(pa rseInt($(" #formulaAu toNumber") .val())),p arent.Xrm. Page.data. entity.att ributes.ge t("north52 _formulaty pe").fireO nChange()} ,North52.F ormulaEdit or.Registe rInit=func tion(){$(" #formulaNa me").val(N orth52.For mulaEditor .SetDefaul tName()),$ ("#formula Type").val (parent.Xr m.Page.dat a.entity.a ttributes. get("north 52_formula type").get Value()),$ ("#formula Event").va l(parent.X rm.Page.da ta.entity. attributes .get("nort h52_pipeli neevent"). getValue() ),$("#form ulaMode"). val(parent .Xrm.Page. data.entit y.attribut es.get("no rth52_mode ").getValu e()),$("#f ormulaAuto Number").v al(parent. Xrm.Page.d ata.entity .attribute s.get("nor th52_auton umbervalue ").getValu e()),$("#f ormulaDisp layFormat" ).val(pare nt.Xrm.Pag e.data.ent ity.attrib utes.get(" north52_di splayforma t").getVal ue()),$("# formulaPip elineStage ").val(par ent.Xrm.Pa ge.data.en tity.attri butes.get( "north52_p ipelinesta ge").getVa lue()),$(" #formulaTr aceLevel") .val(paren t.Xrm.Page .data.enti ty.attribu tes.get("n orth52_tra cinglevel" ).getValue ()),$("#fo rmulaCateg ory").val( parent.Xrm .Page.data .entity.at tributes.g et("north5 2_category ").getValu e()),$("#f ormulaSubC ategory"). val(parent .Xrm.Page. data.entit y.attribut es.get("no rth52_subc ategory"). getValue() ),$("#form ulaExecuti onOrder"). val(parent .Xrm.Page. data.entit y.attribut es.get("no rth52_exec utionorder ").getValu e()),$("#f ormulaGetD ataXml").v al(North52 .FormulaEd itor.GetPa yLoadEleme nt(4)),$(" #formulaCl ientSideSy ncAsync"). val(North5 2.FormulaE ditor.GetP ayLoadElem ent(5)),$( "#formulaC lientSideP reventDefa ultAction" ).val(Nort h52.Formul aEditor.Ge tPayLoadEl ement(6)), North52.Fo rmulaEdito r.ShowHide ClientSide (),1==pare nt.Xrm.Pag e.ui.getFo rmType()?N orth52.For mulaEditor .RegisterF ormulaType (!1):North 52.Formula Editor.Reg isterFormu laType(!0) },North52. FormulaEdi tor.ShowHi deClientSi deSaveMode =function( ){var a=$( "#formulaT ype").val( ),b=North5 2.FormulaE ditor.GetP ayLoadElem ent(3);if( 217890004! =a&&217890 003!=a&&21 7890015!=a ||1!=North 52.Formula Editor.IsO nSaveSelec ted())$("# formulaCli entSideSav eMode").va l("0"),$(" #controlGr oupFormula ClientSide SaveMode") .hide();el se{$("#con trolGroupF ormulaClie ntSideSave Mode").sho w();var c= b.split("; ");$("#for mulaClient SideSaveMo de").val(c )}},North5 2.FormulaE ditor.Show HideClient Side=funct ion(){var  a=$("#form ulaMode"). val();2178 90002!=a?( $("#contro lGroupForm ulaClientS idePayLoad ").show(), $("#contro lGroupForm ulaGetData Xml").show (),$("#con trolGroupF ormulaClie ntSideSync Async").sh ow(),$("#c ontrolGrou pFormulaCl ientSidePr eventDefau ltAction") .show()):( $("#contro lGroupForm ulaClientS idePayLoad ").hide(), $("#contro lGroupForm ulaGetData Xml").hide (),$("#con trolGroupF ormulaClie ntSideSync Async").hi de(),$("#c ontrolGrou pFormulaCl ientSidePr eventDefau ltAction") .hide())}, North52.Fo rmulaEdito r.ShowHide PlugInOnly Fields=fun ction(){va r a=$("#fo rmulaType" ).val();21 7890013==a ||21789000 3==a||2178 90001==a|| 217890004= =a||217890 005==a||21 7890015==a ?($("#cont rolGroupFo rmulaExecu tionOrder" ).show(),$ ("#control GroupPipel ineStage") .show()):( $("#contro lGroupForm ulaExecuti onOrder"). hide(),$(" #controlGr oupPipelin eStage").h ide())},No rth52.Form ulaEditor. IsOnSaveSe lected=fun ction(){va r a=!1,b=$ ("#metadat aproperty" ).val();if (null==b)r eturn a;fo r(var c=0; c<b.length ;c++)if(b[ c].indexOf ("onsave") >-1){a=!0; break}retu rn a},Nort h52.Formul aEditor.Ge tPayLoadEl ement=func tion(a){va r b="21789 0000",c=pa rent.Xrm.P age.data.e ntity.attr ibutes.get ("north52_ clientside datapayloa d").getVal ue();retur n null!=c& &c.split(" :").length >a&&(b=c.s plit(":")[ a]),b},Nor th52.Formu laEditor.R egisterHid e=function (a){$("#co ntrolGroup FormulaNam e").show() ,$("#contr olGroupFor mulaType") .show(),$( "#controlG roupFormul aMode").sh ow(),$("#c ontrolGrou pFormulaEv ent").hide (),$("#con trolGroupF ormulaAuto Number").h ide(),$("# controlGro upFormulaD isplayForm at").hide( ),$("#cont rolGroupFo rmulaSourc eEntity"). show(),$(" #controlGr oupFormula SourceProp erty").hid e(),$("#co ntrolGroup FormulaTar getEntity" ).hide(),$ ("#control GroupFormu laTargetPr operty").h ide(),$("# controlGro upFormulaS ourceRelat ionship"). hide(),$(" #controlGr oupPipelin eStage").s how(),$("# controlGro upFormulaT raceLevel" ).show(),$ ("#control GroupFormu laCategory ").show(), $("#contro lGroupForm ulaSubCate gory").sho w(),$("#co ntrolGroup FormulaExe cutionOrde r").show() ,$("#contr olGroupFor mulaDeploy mentSoluti on").show( ),$("#form ulaMode op tion[value ='21789000 0']").attr ("disabled ",!1),$("# formulaMod e option[v alue='2178 90001']"). attr("disa bled",!1), $("#formul aMode opti on[value=' 217890002' ]").attr(" disabled", !1),parent .Xrm.Page. getAttribu te("north5 2_autonumb ervalue"). setRequire dLevel("no ne"),paren t.Xrm.Page .getAttrib ute("north 52_validat ionmessage ").setRequ iredLevel( "none"),$( "formulaAu toNumber") .prop("req uired",!1) ,0==a&&$(" #formulaAu toNumber") .val(""),0 ==a&&paren t.Xrm.Page .data.enti ty.attribu tes.get("n orth52_aut onumberval ue").setVa lue(null), 0==a&&pare nt.Xrm.Pag e.data.ent ity.attrib utes.get(" north52_so urceentity name").set Value("")} ,North52.F ormulaEdit or.Registe rFormulaTy pe=functio n(a){North 52.Formula Editor.Reg isterHide( a),North52 .SourceEnt ity.Initia lize();var  b=$("#for mulaType") .val();217 89e4==b||2 17890011== b||2178900 07==b||217 890012==b| |217890016 ==b||21789 0017==b?($ ("#control GroupFormu laDisplayF ormat").sh ow(),$("#c ontrolGrou pFormulaSo urceEntity ").show(), $("#formul aMode opti on[value=' 217890001' ]").attr(" disabled", !0),$("#fo rmulaMode  option[val ue='217890 000']").at tr("disabl ed",!0),0= =a&&$("#fo rmulaMode" ).val("217 890002"),0 ==a&&$("#f ormulaPipe lineStage" ).val("217 890000")): 217890017= =b?(North5 2.FormulaE ditor.Regi sterHide() ,parent.Xr m.Page.dat a.entity.a ttributes. get("north 52_sourcee ntityname" ).setValue ("north52_ command"), $("#formul aMode opti on[value=' 217890001' ]").attr(" disabled", !0),$("#fo rmulaMode  option[val ue='217890 000']").at tr("disabl ed",!0),0= =a&&$("#fo rmulaMode" ).val("217 890002"),0 ==a&&$("#f ormulaPipe lineStage" ).val("217 890000")): 217890018= =b||217890 019==b?($( "#controlG roupFormul aSourceEnt ity").show (),$("#for mulaMode o ption[valu e='2178900 01']").att r("disable d",!0),$(" #formulaMo de option[ value='217 890000']") .attr("dis abled",!0) ,0==a&&$(" #formulaMo de").val(" 217890002" ),0==a&&$( "#formulaP ipelineSta ge").val(" 217890000" )):2178900 13==b||217 890020==b? ($("#contr olGroupFor mulaEvent" ).show(),$ ("#control GroupFormu laSourceEn tity").sho w(),$("#co ntrolGroup FormulaSou rcePropert y").show() ,$("#formu laMode opt ion[value= '217890001 ']").attr( "disabled" ,!0),$("#f ormulaMode  option[va lue='21789 0000']").a ttr("disab led",!0),0 ==a&&$("#f ormulaMode ").val("21 7890002"), 0==a&&$("# formulaPip elineStage ").val("21 7890001")) :217890004 ==b?($("#c ontrolGrou pFormulaEv ent").show (),$("#con trolGroupF ormulaSour ceEntity") .show(),$( "#controlG roupFormul aSourcePro perty").sh ow(),paren t.Xrm.Page .getAttrib ute("north 52_pipelin estage").s etValue(21 789e4),0== a&&$("#for mulaMode") .val("2178 90002"),0= =a&&$("#fo rmulaPipel ineStage") .val("2178 90000")):2 17890001== b?($("#con trolGroupF ormulaEven t").show() ,$("#contr olGroupFor mulaSource Entity").s how(),$("# controlGro upFormulaS ourcePrope rty").show (),$("#con trolGroupF ormulaTarg etEntity") .show(),$( "#controlG roupFormul aTargetPro perty").sh ow(),$("#c ontrolGrou pFormulaSo urceRelati onship").s how(),$("# formulaMod e option[v alue='2178 90001']"). attr("disa bled",!0), $("#formul aMode opti on[value=' 217890000' ]").attr(" disabled", !0),0==a&& $("#formul aMode").va l("2178900 02"),0==a& &$("#formu laPipeline Stage").va l("2178900 01")):2178 90003==b?( $("#contro lGroupForm ulaEvent") .show(),$( "#controlG roupFormul aSourceEnt ity").show (),$("#con trolGroupF ormulaSour ceProperty ").show(), $("#contro lGroupForm ulaTargetE ntity").sh ow(),$("#c ontrolGrou pFormulaTa rgetProper ty").show( ),0==a&&$( "#formulaM ode").val( "217890002 "),0==a&&$ ("#formula PipelineSt age").val( "217890002 ")):217890 015==b?($( "#controlG roupFormul aEvent").s how(),$("# controlGro upFormulaS ourceEntit y").show() ,$("#contr olGroupFor mulaSource Property") .show(),$( "#formulaM ode option [value='21 7890002']" ).attr("di sabled",!0 ),$("#form ulaMode op tion[value ='21789000 0']").attr ("disabled ",!0),0==a &&$("#form ulaMode"). val("21789 0001"),0== a&&$("#for mulaPipeli neStage"). val("21789 0000")):21 7890014==b ?($("#cont rolGroupFo rmulaSourc eEntity"). show(),$(" #formulaMo de").val(" 217890001" ),$("#form ulaMode op tion[value ='21789000 2']").attr ("disabled ",!0),$("# formulaMod e option[v alue='2178 90000']"). attr("disa bled",!0), 0==a&&$("# formulaMod e").val("2 17890001") ,0==a&&$(" #formulaPi pelineStag e").val("2 17890000") ):21789000 5==b&&($(" #controlGr oupFormula AutoNumber ").show(), $("#contro lGroupForm ulaSourceE ntity").sh ow(),$("#c ontrolGrou pFormulaSo urceProper ty").show( ),$("#cont rolGroupFo rmulaTarge tEntity"). show(),$(" #controlGr oupFormula TargetProp erty").sho w(),$("#co ntrolGroup FormulaEve nt").show( ),$("#form ulaMode op tion[value ='21789000 1']").attr ("disabled ",!0),$("# formulaMod e option[v alue='2178 90000']"). attr("disa bled",!0), 0==a&&$("# formulaMod e").val("2 17890002") ,0==a&&$(" #formulaPi pelineStag e").val("2 17890002") ,0==a&&$(" #formulaEv ent").val( "217890000 "),parent. Xrm.Page.g etAttribut e("north52 _autonumbe rvalue").s etRequired Level("req uired"),0= =a&&($("#f ormulaAuto Number").v al(parseIn t(0)),pare nt.Xrm.Pag e.data.ent ity.attrib utes.get(" north52_au tonumberva lue").setV alue(parse Int(0))),$ ("formulaA utoNumber" ).prop("re quired",!0 )),0==a&&N orth52.For mulaEditor .RegisterS ync(),Nort h52.Formul aEditor.Sh owHidePlug InOnlyFiel ds(),North 52.Formula Editor.Sho wHideClien tSide()},N orth52.For mulaEditor .SetCursor PositionFo rmulaBox=f unction(){ var a="cur sorPositio nFormulaBo x";localSt orage.setI tem(a,Nort h52.Formul aEditor.ge tCusror("f ormulabox" ))},North5 2.FormulaE ditor.Togg leFormulaB ox=functio n(){if("21 px"==docum ent.getEle mentById(" formulabox ").style.h eight)docu ment.getEl ementById( "formulabo x").style. height="30 0px",docum ent.getEle mentById(" ss").style .width="99 .7%",windo w.fbxx.des troy(),nul l==window. fbxx;else{ document.g etElementB yId("formu labox").st yle.height ="21px",do cument.get ElementByI d("ss").st yle.width= "99.7%";va r a=$("#ss ").data("s pread"),b= document.g etElementB yId("formu labox").va lue,c=a.ge tActiveShe et(),d=c.g etActiveRo wIndex(),e =c.getActi veColumnIn dex();c.ge tCell(d,e) .value(b), window.fbx x=new GcSp read.Sheet s.FormulaT extBox(doc ument.getE lementById ("formulab ox")),wind ow.fbxx.sp read(a),wi ndow.fbxx. autoComple te(!1),win dow.fbxx.s howHelp(!1 )}},North5 2.FormulaE ditor.Togg leColumnOr =function( ){for(var  a=$("#ss") .wijspread ("spread") ,b=a.getAc tiveSheet( ),c=b.getS elections( ),d=c[0].c ol;d<c[0]. col+c[0].c olCount;d+ +)"Conditi on"==b.get Value(0,d) ?b.getCell (0,d).valu e("Conditi on-Or"):b. getCell(0, d).value(" Condition" )},North52 .FormulaEd itor.Defau ltFocus=fu nction(){1 ==$("#form ula").is(" :visible") ?parent.Xr m.Page.ui. controls.g et("WebRes ource_form ulaeditor" ).setFocus ():parent. Xrm.Page.u i.controls .get("WebR esource_fo rmulaedito r").setFoc us()},Nort h52.Formul aEditor.Sh owSearchFu nction=fun ction(){$( "#treefunc tions").cs s({top:0}) ,$("#txtFi nd").show( )},North52 .FormulaEd itor.HideS earchFunct ion=functi on(){$("#t reefunctio ns").css({ top:-20}), $("#txtFin d").hide() ,North52.F ormulaEdit or.SearchC lear()},No rth52.Form ulaEditor. SearchClea r=function (a){$(":wi jmo-wijtre enode",$(a )).each(fu nction(){$ (this).sho w()}),$(": wijmo-wijt reenode",$ (a)).each( function() {$(this).d ata("nodes ").length& &$(this).w ijtreenode ("collapse ")})},Nort h52.Formul aEditor.Ex pandTree=f unction(a) {$(":wijmo -wijtreeno de",$(a)). each(funct ion(){$(th is).data(" nodes").le ngth&&$(th is).wijtre enode("exp and")})},N orth52.For mulaEditor .Search=fu nction(a,b ){$(":wijm o-wijtreen ode",$(a)) .each(func tion(){var  c=$(this) .text().to LowerCase( ),d=$(this )[0].paren tNode.pare ntNode.inn erText.toL owerCase() .replace(" \r\n\r\n\r \n\r\n","" );c===b||c .indexOf(b )>=0?$(thi s).show(): "#treesour ce"==a&&0= =d.startsW ith("sourc e")&&(d=== b||d.index Of(b)>=0)? $(this).sh ow():$(thi s).hide()} )},North52 .FormulaEd itor.IsInM ultipleMod e=function (){var a=0 ,b=!1,c=$( "#ss").wij spread("sp read");ret urn c.shee ts.forEach (function( b){"Action s"!=b.getN ame()&&"Ca lculations "!=b.getNa me()&&"Con figuration "!=b.getNa me()&&a++} ),a>=2&&(b =!0),b},No rth52.Form ulaEditor. DTLoad=fun ction(){va r a=$("#ss ").data("s pread"),b= parent.Xrm .Page.data .entity.at tributes.g et("north5 2_formulad escription ").getValu e();a.from JSON(JSON. parse(b)), North52.Fo rmulaEdito r.BuildTre es("Calcul ations"),N orth52.For mulaEditor .BuildTree s("Actions ")},North5 2.FormulaE ditor.Togg leDTAdvanc edMode=fun ction(){va r a=$("#ss ").wijspre ad("spread "),b=a.get ActiveShee t();"Actio ns"!=b.get Name()&&"C alculation s"!=b.getN ame()&&(1= =b.getRow( 2).visible ()?b.setRo wVisible(2 ,!1):b.set RowVisible (2,!0))},N orth52.For mulaEditor .DTGenerat eMaster=fu nction(){v ar a=0,b=$ ("#ss").da ta("spread "),c="";b. sheets.for Each(funct ion(b){"Ac tions"!=b. getName()& &"Calculat ions"!=b.g etName()&& "Configura tion"!=b.g etName()&& (a++,c=c+" \n\n"+Nort h52.Formul aEditor.DT Generate(b )+" ,")}), c=c.slice( 0,-1);for( var d="",e =b.getShee tFromName( "Calculati ons"),f=1; f<=100&&nu ll!=e.getV alue(f,0)& &null!=e.g etValue(f, 1);f++)if( null!=e.ge tValue(f,2 )&&"Local" !=e.getVal ue(f,2)){v ar g=e.get Value(f,0) ,h=e.getVa lue(f,1);d +=String.f ormat("\n  SetVar('{0 }', {1})," ,g,h)}retu rn a<=1?c: String.for mat("Multi pleDecisio nTable(\n{ 0} \n\n {1 }\n\n)",d, c)},North5 2.FormulaE ditor.DTGe nerate=fun ction(a){f or(var b=$ ("#ss").da ta("spread "),c=0,e=" ",f="",g=" ",h=["="," >","<","!" ,"%"],i="D ecisionTab le(\n _Ags _ \n _IfTr ue_ \n\n,  '"+North52 .FormulaEd itor.FindC urrentTag( a,-1)+"')" ,j="",k=b. getSheetFr omName("Ca lculations "),l=1;l<= 100&&null! =k.getValu e(l,0)&&nu ll!=k.getV alue(l,1); l++)if(nul l==k.getVa lue(l,2)|| "Global"!= k.getValue (l,2)){var  m=k.getVa lue(l,0),n =k.getValu e(l,1);j+= String.for mat("\n Se tVar('{0}' , {1}),",m ,n)}for(va r o=3;o<=1 e3;o++){c+ +;for(var  p=parent.X rm.Page.da ta.entity. attributes .get("nort h52_source entityname ").getValu e(),q="",r ="",s="",t ="",u=" ", v=0;v<=100 ;v++){var  w=" and ", x=" ",y="  ",z="";u="  ";var A=S tring(a.ge tValue(o,v ));if(null !=A&&"null "!=A){if(e =a.getValu e(0,v),f=S tring(a.ge tValue(o-( c+1),v)),g =String(a. getValue(o -c,v)),"Co ndition"== e||1==e.st artsWith(" Condition- Or")){h.in dexOf(A.su bstring(0, 1))==-1&&( u="="),1== e.startsWi th("Condit ion-Or")&& a.getValue (0,v+1)==e &&(w=" or  "),1==e.st artsWith(" Condition- Or")&&1==a .getValue( 0,v+1).sta rtsWith("C ondition-O r-Compound ")&&(w=" o r "),1!=e. startsWith ("Conditio n-Or")||0! =v&&a.getV alue(0,v-1 )==e||(x="  ( "),1==e .startsWit h("Conditi on-Or")&&a .getValue( 0,v+1)!=e& &(y=" ) ") ,A.indexOf ("{{{{")>= 0?q=q+x+St ring.forma t(" {0} "+ y+w,A.repl ace(/\{{{( .*?)\}}}/g ,"$1")):A. indexOf("{ {{")>=0?q= q+x+String .format("  {1}({0}) =  true "+y+ w,a.getVal ue(o-c,v), A.replace( /\{{{(.*?) \}}}/g,"$1 ")):A.inde xOf("{{")> =0?q=q+x+a .getValue( o-c,v)+" " +A.replace (/\{{(.*?) \}}/g,"xCa cheGetGlob al( '$1' ) ")+y+w:A.s tartsWith( "((")&&A.e ndsWith(") )")?(A=Str ing.format (" Between ("+a.getVa lue(o-c,v) +", {0}, ' Both') ",A .replace(" ((","").re place("))" ,"")),q=q+ x+A+y+w):A .startsWit h("((")&&A .endsWith( "])")?(A=S tring.form at(" Betwe en("+a.get Value(o-c, v)+", {0},  'Left') " ,A.replace ("((",""). replace("] )","")),q= q+x+A+y+w) :A.startsW ith("([")& &A.endsWit h("))")?(A =String.fo rmat(" Bet ween("+a.g etValue(o- c,v)+", {0 }, 'Right' ) ",A.repl ace("(["," ").replace ("))","")) ,q=q+x+A+y +w):A.star tsWith("([ ")&&A.ends With("])") ?(A=String .format("  Between("+ a.getValue (o-c,v)+",  {0}, 'Non e') ",A.re place("([" ,"").repla ce("])","" )),q=q+x+A +y+w):q=A. split("{") .length-1> =2?q+x+Str ing.format (" In({0},  {1}) = tr ue "+y+w,a .getValue( o-c,v),A): q+x+String .format("  {0} {1} {2 } "+y+w,a. getValue(o -c,v),u,A) ;for(var B =North52.F ormulaEdit or.GetWord sBetweenCu rlies(q),C =0;C<B.len gth;C++){v ar D="",E= "",F=b.get SheetIndex ("Calculat ions"),G=B [C].replac e("{",""). replace("} ",""),H=No rth52.Form ulaEditor. SheetSearc h(G,F);if( H.foundRow Index!=-1& &(D=String .format("G etVar('{0} ')",G)),G= B[C],""==D ){var I=$( "#treesour ce").wijtr ee("findNo deByText", "Source"); D=North52. FormulaEdi tor.NodeSe arch(G,I)} if(""==D&& (I=$("#tre esource"). wijtree("f indNodeByT ext",f+"{V alue}"),D= North52.Fo rmulaEdito r.NodeSear ch(G,I))," "==D){var  I=$("#tree related"). wijtree("f indNodeByT ext","Rela ted (N:1)" );D=North5 2.FormulaE ditor.Node Search(G,I )}""==D&&( I=$("#tree related"). wijtree("f indNodeByT ext",f+"{V alue}"),D= North52.Fo rmulaEdito r.NodeSear ch(G,I))," "==D&&(D=G ),C+1<B.le ngth&&(E=" , "),q=q.r eplace("{" +B[C]+"}", D+E)}}else  e="Action Parameter" ,"null"!=g &&"["==g.s ubstring(0 ,1)&&(e="A ctionUpdat e"),"null" ==f&&"null "==g&&(e=" ActionComm and");if(" ActionUpda te"==e){va r J=g.repl ace("[","" ).replace( "]","").sp lit(".")[1 ],K="";A.i ndexOf("{{ {")>=0?A=A .replace(/ \{{{(.*?)\ }}}/g,"$1" ):A.indexO f("{{")>=0 &&(A=A.rep lace(/\{{( .*?)\}}/g, "xCacheGet Global( '$ 1' )")),K= String.for mat(" SetA ttribute(' {0}', {1}) ",J,A),s=s +K+",";for (var D="?? ",L=North5 2.FormulaE ditor.GetW ordsBetwee nCurlies(s ),M=0;M<L. length;M++ ){var I=$( "#treesour ce").wijtr ee("findNo deByText", f+"{Value} ");if(null !=I&&0!=I. getNodes() .length){f or(var N=0 ;N<I.getNo des().leng th;N++)if( L[M]==I.ge tNodes()[N ].options. text){D=I. getNodes() [N].option s.params;b reak}s=s.r eplace("{" +L[M]+"}", D)}}if("?? "==D&&L.le ngth>0){va r O=new Gc Spread.She ets.Search Condition; O.searchSt ring=L[0]. replace("{ ","").repl ace("}","" ),O.startS heetIndex= b.getSheet Index("Cal culations" ),O.endShe etIndex=b. getSheetIn dex("Calcu lations"), O.searchOr der=GcSpre ad.Sheets. SearchOrde r.NOrder,O .searchTar get=GcSpre ad.Sheets. SearchFoun dFlags.Cel lText;var  H=b.search (O);H.foun dRowIndex! =-1&&(D=St ring.forma t("GetVar( '{0}')",O. searchStri ng),s=s.re place("{"+ L[0]+"}",D ))}"??"==D &&L.length >0&&(D=Str ing.format ("GetVar(' {0}')",O.s earchStrin g),s=s.rep lace("{"+L [0]+"}",D) )}if("Acti onCommand" ==e){var O =new GcSpr ead.Sheets .SearchCon dition;O.s earchStrin g=A.replac e("{",""). replace("} ",""),O.st artSheetIn dex=b.getS heetIndex( "Actions") ,O.endShee tIndex=b.g etSheetInd ex("Action s"),O.sear chOrder=Gc Spread.She ets.Search Order.NOrd er,O.searc hTarget=Gc Spread.She ets.Search FoundFlags .CellText; var H=b.se arch(O);H. foundRowIn dex==-1?t= A.indexOf( "{{{")>=0? t+", "+A.r eplace(/\{ {{(.*?)\}} }/g,"$1"): t+", "+A:( z=b.getShe etFromName ("Actions" ).getValue (H.foundRo wIndex,H.f oundColumn Index+1),t =t+", "+z) }"ActionPa rameter"== e&&(z="+=" ==g?String .format("S etVar('{0} ', GetVar( '{0}', 0)  + {1})",f, A):"-="==g ?String.fo rmat("SetV ar('{0}',  GetVar('{0 }', 0) - { 1})",f,A): "=="==g?St ring.forma t("SetVar( '{0}', {1} )",f,A):A. indexOf("{ {{")>=0?A. replace(/\ {{{(.*?)\} }}/g,"$1") :String.fo rmat(g,A), t=t+", "+z )}}if(""!= s){s=s.sub string(0,s .length-1) ;var P=Nor th52.Formu laEditor.r etrievePri maryIdAttr ibute(p,St ring.forma t("[{0}.{0 }id]",p)); r=String.f ormat("Upd ateRecord( '{0}', [{0 }.{2}],{1}  )",p,s,P) }else t=t. substring( 1,t.length );if(q=q.r eplace(/an d $/,"")," "==q&&r+t= ="")break; ""==q&&(q= "true"),r+ t==""&&(r= "true");va r Q=String .format("\ nIfTrue({0 }, {1}) ,\ n _IfTrue_ ",q,r+t);i =i.replace ("_IfTrue_ ",Q)}retur n i="Actio nParameter "!=e||"+=" !=g&&"-="! =g&&"=="!= g?i.replac e(",\n _If True_"," \ n "):i.rep lace(",\n  _IfTrue_", " \n  \n ,  IfTrue(tr ue, GetVar ('"+f+"',  0) ) \n"), i=i.replac e("_Ags_", j),i=i.rep lace("_IfT rue_","'No Op'")},Nor th52.Formu laEditor.D TInit=func tion(){var  a=$("#ss" ),b=parent .Xrm.Page. data.entit y.attribut es.get("no rth52_form uladescrip tion").get Value();if (a[0].chil dElementCo unt>0){var  c=$("#ss" ).data("sp read");ret urn window .fbxx.spre ad(c),wind ow.fbxx.au toComplete (!1),void  window.fbx x.showHelp (!1)}var c =new GcSpr ead.Sheets .Spread(do cument.get ElementByI d("ss"),{s heetCount: 3});if(win dow.fbxx.s pread(c),w indow.fbxx .autoCompl ete(!1),wi ndow.fbxx. showHelp(! 1),c.newTa bVisible(! 1),c.scrol lbarShowMa x(!0),c.us eWijmoThem e=!0,null! =b&&b.leng th>0&&b.in dexOf("8.4 0.20151.5" )>0){b=b.s ubstring(b .indexOf(" /*")+2,b.i ndexOf("*/ ")),c.from JSON(JSON. parse(b)), North52.Fo rmulaEdito r.BuildTre es("Calcul ations"),N orth52.For mulaEditor .BuildTree s("Actions ");var d=c .getSheetF romName("C onfigurati on");if(nu ll!=d){var  e=c.getSh eet(0);e.t ag(d.getVa lue(1,0)+" |false"),c .removeShe et(c.getSh eetIndex(" Configurat ion"))}var  f=$("#ss" ).data("sp read").get ActiveShee t();North5 2.FormulaE ditor.SetE xitMenu(f) }else{var  e=c.getShe et(0);Nort h52.Formul aEditor.De cisionTabl eInit(c),e .tag("true |false"),N orth52.For mulaEditor .SetExitMe nu(e)}Nort h52.Formul aEditor.De cisionTabl eEvents()} ,North52.F ormulaEdit or.Decisio nTableInit =function( a){var b=a .getSheet( 0),c=a.get Sheet(1),d =a.getShee t(2);a.get Sheet(0).s etName("De cisionTabl e"),a.getS heet(1).se tName("Cal culations" ),a.getShe et(2).setN ame("Actio ns"),b.get Cell(0,0). value("Con dition"),b .getCell(0 ,1).value( "Action"), b.getCell( 0,0).backC olor("#ffd f80"),b.ge tCell(1,0) .backColor ("#ffdf80" ),b.getCel l(2,0).bac kColor("#f fdf80"),b. getCell(0, 0).font("i talic 9pt  arial"),b. getCell(1, 0).font("b old 10pt a rial"),b.g etCell(1,0 ).wordWrap (!0),b.get Cell(0,1). backColor( "#80c784") ,b.getCell (1,1).back Color("#80 c784"),b.g etCell(2,1 ).backColo r("#80c784 "),b.getCe ll(0,1).fo nt("italic  9pt arial "),b.getCe ll(1,1).fo nt("bold 1 0pt arial" ),b.getCel l(1,1).wor dWrap(!0), c.setColum nCount(6,G cSpread.Sh eets.Sheet Area.viewp ort),c.set ColumnWidt h(0,150,Gc Spread.She ets.SheetA rea.viewpo rt),c.setC olumnWidth (1,800,GcS pread.Shee ts.SheetAr ea.viewpor t),c.getCe ll(0,0).va lue("Calcu lation Nam e"),c.getC ell(0,1).v alue("Calc ulation Va lue"),c.ge tCell(0,2) .value("Sc ope"),c.ge tCell(0,0) .backColor ("#d3d3d3" ),c.getCel l(0,1).bac kColor("#d 3d3d3"),c. getCell(0, 2).backCol or("#d3d3d 3"),c.getC ell(0,0).f ont("bold  10pt arial "),c.getCe ll(0,1).fo nt("bold 1 0pt arial" ),c.getCel l(0,2).fon t("bold 10 pt arial") ,d.setColu mnCount(6, GcSpread.S heets.Shee tArea.view port),d.se tColumnWid th(0,150,G cSpread.Sh eets.Sheet Area.viewp ort),d.set ColumnWidt h(1,800,Gc Spread.She ets.SheetA rea.viewpo rt),d.getC ell(0,0).v alue("Acti on Name"), d.getCell( 0,1).value ("Action V alue"),d.g etCell(0,0 ).backColo r("#d3d3d3 "),d.getCe ll(0,1).ba ckColor("# d3d3d3"),d .getCell(0 ,2).backCo lor("#d3d3 d3"),d.get Cell(0,0). font("bold  10pt aria l"),d.getC ell(0,1).f ont("bold  10pt arial "),d.getCe ll(0,2).fo nt("bold 1 0pt arial" ),b.setRow Visible(2, !1),b.setR owHeight(1 ,35,GcSpre ad.Sheets. SheetArea. viewport); for(var e= 0;e<=50;e+ +)b.setCol umnWidth(e ,120,GcSpr ead.Sheets .SheetArea .viewport) ,b.getColu mn(e).hAli gn(GcSprea d.Sheets.H orizontalA lign.left) ;b.setRowC ount(35),b .setColumn Count(29), b.setActiv eCell(4,1) },North52. FormulaEdi tor.Decisi onTableEve nts=functi on(){var a =$("#ss"). wijspread( "spread"), b=a.getShe etFromName ("Calculat ions"),c=a .getSheetF romName("A ctions");c .bind(GcSp read.Sheet s.Events.E nterCell,f unction(a, b){North52 .FormulaEd itor.Build Trees(b.sh eetName)}) ,b.bind(Gc Spread.She ets.Events .CellChang ed,functio n(a,b){Nor th52.Formu laEditor.B uildTrees( b.sheetNam e);var c=n ew GcSprea d.Sheets.C omboBoxCel lType;c.it ems([{text :"Local",v alue:"Loca l"},{text: "Global",v alue:"Glob al"}]),1== North52.Fo rmulaEdito r.IsInMult ipleMode() &&b.col<2& &b.row>0&& null!=b.sh eet.getVal ue(b.row,0 )&&null!=b .sheet.get Value(b.ro w,1)&&(b.s heet.setCe llType(b.r ow,2,c,GcS pread.Shee ts.SheetAr ea.viewpor t),b.sheet .setValue( b.row,2,"L ocal"))}), a.bind("Ed itEnded",f unction(a, b){$("#ss" ).wijsprea d("spread" );null!=b. editingTex t&&"="==b. editingTex t.substrin g(0,1)&&"= ="!=b.edit ingText.su bstring(0, 2)&&b.shee t.clear(b. row,b.col, 1,1,GcSpre ad.Sheets. SheetArea. viewport,G cSpread.Sh eets.Stora geType.Dat a),1!=b.ro w&&2!=b.ro w||North52 .FormulaEd itor.Build Trees("Cal culations" )}),a.bind (GcSpread. Sheets.Eve nts.SheetN ameChanged ,function( a,b){"Calc ulations"= =b.oldValu e?b.sheet. setName("C alculation s"):"Actio ns"==b.old Value&&b.s heet.setNa me("Action s")}),a.bi nd(GcSprea d.Sheets.E vents.Acti veSheetCha nged,funct ion(a,b){$ ("#context Menu").wij menu("deac tivate"),$ ("#context Menu").wij menu("hide AllMenus") ,North52.F ormulaEdit or.SetExit Menu(b.new Sheet)})}, North52.Fo rmulaEdito r.SubDT=fu nction(){v ar a=$("#s s").wijspr ead("sprea d"),b="Dec isionTable "+String(a .sheets.le ngth-3);a. addSheet(0 ,new $.wij mo.wijspre ad.Sheet(b ));var c=a .getSheetF romName(b) ;c.getCell (0,0).valu e("Conditi on"),c.get Cell(0,1). value("Act ion"),c.ge tCell(0,0) .backColor ("#ffdf80" ),c.getCel l(1,0).bac kColor("#f fdf80"),c. getCell(2, 0).backCol or("#ffdf8 0"),c.getC ell(0,0).f ont("itali c 9pt aria l"),c.getC ell(1,0).f ont("bold  10pt arial "),c.getCe ll(1,0).wo rdWrap(!0) ,c.getCell (0,1).back Color("#80 c784"),c.g etCell(1,1 ).backColo r("#80c784 "),c.getCe ll(2,1).ba ckColor("# 80c784"),c .getCell(0 ,1).font(" italic 9pt  arial"),c .getCell(1 ,1).font(" bold 10pt  arial"),c. getCell(1, 1).wordWra p(!0),c.se tRowVisibl e(2,!1),c. setRowHeig ht(1,35,Gc Spread.She ets.SheetA rea.viewpo rt);for(va r d=0;d<=5 0;d++)c.se tColumnWid th(d,120,G cSpread.Sh eets.Sheet Area.viewp ort),c.get Column(d). hAlign(GcS pread.Shee ts.Horizon talAlign.l eft);retur n c.setRow Count(35), c.setColum nCount(29) ,c.setActi veCell(4,1 ),c.tag("t rue|false" ),c},North 52.Formula Editor.Set ExitMenu=f unction(a) {if("Calcu lations"== a.getName( )||"Action s"==a.getN ame())$("# cbx_exitfi rstmatch") .attr("dis abled",!0) ,$("#cbx_e xitfirstma tchall").a ttr("disab led",!0);e lse{$("#cb x_exitfirs tmatch").r emoveAttr( "disabled" ),$("#cbx_ exitfirstm atchall"). removeAttr ("disabled ");var b=N orth52.For mulaEditor .FindCurre ntTag(a,0) ;"true"==b ?$("#cbx_e xitfirstma tch").prop ("checked" ,!0):$("#c bx_exitfir stmatch"). prop("chec ked",!1);v ar b=North 52.Formula Editor.Fin dCurrentTa g(a,1);"tr ue"==b?$(" #cbx_exitf irstmatcha ll").prop( "checked", !0):$("#cb x_exitfirs tmatchall" ).prop("ch ecked",!1) }},North52 .FormulaEd itor.Sheet Search=fun ction(a,b) {var c=$(" #ss").data ("spread") ,d=new GcS pread.Shee ts.SearchC ondition;r eturn d.se archString =a,d.start SheetIndex =b,d.endSh eetIndex=b ,d.searchO rder=GcSpr ead.Sheets .SearchOrd er.NOrder, d.searchTa rget=GcSpr ead.Sheets .SearchFou ndFlags.Ce llText,c.s earch(d)}, North52.Fo rmulaEdito r.NodeSear ch=functio n(a,b){if( null!=b&&b .getNodes( ).length>0 )for(var c =0;c<b.get Nodes().le ngth;c++)i f(a==b.get Nodes()[c] .options.t ext)return  b.getNode s()[c].opt ions.param s;return"" },North52. FormulaEdi tor.Toggle DecisionTa bleMode=fu nction(){i f(1==$("#f ormula").i s(":visibl e")){var a =$("#ss"); 0==a[0].ch ildElement Count&&(wi ndow.fbxx= new GcSpre ad.Sheets. FormulaTex tBox(docum ent.getEle mentById(" formulabox ")),
        2   North52.Fo rmulaEdito r.DTInit() ),$("#form ula").hide (),$("#ss" ).show(),$ ("#formula box").show (),$("#tre ecalculati ons").show (),$("#tre edecisionc alculation s").show() ,$("#treea ctions").s how()}else {$("#formu la").show( );var b=$( ".CodeMirr or")[0].Co deMirror;b .focus(),b .scrollInt oView({lin e:0,ch:0}) ,$("#ss"). hide(),$(" #formulabo x").hide() ,$("#treec alculation s").hide() ,$("#treed ecisioncal culations" ).hide(),$ ("#treeact ions").hid e()}},Nort h52.Formul aEditor.ge tCusror=fu nction(a){ var b=0,c= document.g etElementB yId(a);try {if(c.sele ctionStart )return c. selectionS tart;if(!d ocument.se lection)re turn 0;var  d="\x0001",e=d ocument.se lection.cr eateRange( ),f=e.dupl icate();f. moveToElem entText(c) ,e.text=d, b=f.text.i ndexOf(d), e.moveStar t("charact er",-1),e. text=""}ca tch(a){ret urn b}retu rn b},Nort h52.Formul aEditor.Re trieveCach eFunction= function() {var a="", b="current Function"; if(localSt orage)try{ a=localSto rage.getIt em(b),loca lStorage.r emoveItem( b)}catch(a ){localSto rage.remov eItem(b)}r eturn a},N orth52.For mulaEditor .ExpandTre eExplore=f unction(a, b){return" Entities"= =b.node._t ext?void N orth52.For mulaEditor .PopulateT reeExplore ("Entities "):void(nu ll!=b.para ms&&b.para ms.length> 0&&"["==b. params.sub string(0,1 )||$("#tre eexplore") .wijtree(" findNodeBy Text",b.no de._text). getNodes() .length>0| |($("#refr eshExplore ").show(), SDK.Metada ta.Retriev eEntity(SD K.Metadata .EntityFil ters.Attri butes,b.pa rams.repla ce("'","") .replace(" '",""),nul l,!1,funct ion(a){Nor th52.Formu laEditor.s uccessRetr ieveAttrib utes(a,b.p arams,"#tr eeexplore" ,b.node._t ext,!1)},N orth52.For mulaEditor .errorRetr ieveAttrib utes)))},N orth52.For mulaEditor .InsertTex tAtCursor= function(a ,b,c,d){if (""!=a&&nu ll!=a||(a= " "),""!=b &&null!=b| |(b=a),nul l==c&&(c=" "),null==d &&(c="")," object"!=t ypeof b){v ar e=$(".C odeMirror" )[0].CodeM irror,f="< br>",g=new  RegExp(f, "g");if(b= b.replace( g,"\n"),1! =$("#formu la").is(": visible")) {var k=$(" #ss").data ("spread") ,l=k.getAc tiveSheet( ),m="Actio ns"!=l.get Name()&&"C alculation s"!=l.getN ame(),n=l. getActiveR owIndex(), o=l.getAct iveColumnI ndex(),p=0 ,q="";if(" 21px"==doc ument.getE lementById ("formulab ox").style .height?(p =window.fb xx.caret() ,q=window. fbxx.text( )):(p=pars eInt(local Storage.ge tItem("cur sorPositio nFormulaBo x")),q=doc ument.getE lementById ("formulab ox").value ),"undefin ed"==typeo f p&&(p=q. length),1= =m&&1==n)l .getCell(n ,o).value( a.replace( "{Value}", "").replac e("{Name}" ,"").repla ce("(Value )","").rep lace("(Nam e)","")),l .getCell(n +1,o).valu e(b);else{ var r=[q.s lice(0,p), b,q.slice( p)].join(" ");1!=m||" treeaction s"!=c&&"tr eecalculat ions"!=c&& "treedecis ioncalcula tions"!=c& &"treesour ce"!=c||(r =[q.slice( 0,p),"{"+a +"}",q.sli ce(p)].joi n("")),1== m&&"Pickli st"==d&&(r =[q.slice( 0,p),"{"+a +"}",q.sli ce(p)].joi n("")),1== m&&"Boolea n"==d&&"1" ==b.trim() &&(r=!0),1 ==m&&"Bool ean"==d&&" 0"==b.trim ()&&(r=!1) ,"21px"==d ocument.ge tElementBy Id("formul abox").sty le.height? (l.getCell (n,o).valu e(r),windo w.fbxx.tex t(r)):docu ment.getEl ementById( "formulabo x").value= r}}else if ("treefunc tions"==c& &null!=e.g etSelectio n()&&e.get Selection( ).length>0 ){var h=e. getSelecti on(),i=b.i ndexOf("'" ),j=b.inde xOf("'",i+ 1);b=b.rep lace(b.sub string(i,j +1),h),i!= -1&&j!=-1? e.replaceS election(b ):e.replac eSelection (b)}else e .replaceSe lection(b) }},North52 .FormulaEd itor.Valid ate=functi on(){var a =$(".CodeM irror")[0] .CodeMirro r.getValue ();a=a.rep lace(/\/\* [\s\S]*?\* \/|([^:]|^ )\/\/.*$/g m,"$1"),a= a.replace( /\«(.*?)\» /,""),a=a. replace(/\ «(.*?)\»/, ""),a=a.re place(/\«( .*?)\»/,"" ),a=a.repl ace(/\«(.* ?)\»/,""), a=a.replac e(/\«(.*?) \»/,"");va r b="Passe d - Basic  formula sy ntax resul t.",c="Run ning - Adv anced Synt ax checker ....",d=[" setstate", "setlookup ","setowne rteam","se towneruser "],e=[" An d "," Or " ," AND ","  OR "],f=" ",g="";Nor th52.Formu laEditor.c learMessag es(),jQuer y.each(d,f unction(b, c){if(a.to LowerCase( ).indexOf( c)>-1)retu rn f=c,!1} ),jQuery.e ach(e,func tion(b,c){ if(a.index Of(c)>-1)r eturn g=c, !1}),a.spl it("(").le ngth-1!=a. split(")") .length-1? b=String.f ormat("Bas ic formula  syntax re sult: Unba lanced num ber of ope n ({0}) &  close brac kets ({1}) .",a.split ("(").leng th-1,a.spl it(")").le ngth-1):a. split("[") .length-1! =a.split(" ]").length -1?b=Strin g.format(" Basic form ula syntax  result: U nbalanced  number of  square ope n ({0}) &  close brac kets ({1}) .",a.split ("[").leng th-1,a.spl it("]").le ngth-1):(a .split("'" ).length-1 )%2!=0?b=" Basic form ula syntax  result: U nbalanced  number of  open & clo se quotes" :""!=f&&21 7890003!=p arent.Xrm. Page.data. entity.att ributes.ge t("north52 _formulaty pe").getVa lue()?b=St ring.forma t("The fun ction {0}  cannot be  used with  this formu la type or  has been  deprecated .",f):""!= g?b=String .format("P lease ensu re that th e followin g, {0} , i s entered  in lower c ase.",g):a .indexOf(" //")>-1&&a .indexOf(" ://")==-1& &(b="Pleas e only use  /* ... */  for comme nts and no t //"),"un defined"!= typeof par ent.Xrm.Pa ge.ui.clea rFormNotif ication?(p arent.Xrm. Page.ui.se tFormNotif ication(b, "INFO","Sy ntaxChecke rBasic"),p arent.Xrm. Page.ui.se tFormNotif ication(c, "INFO","Sy ntaxChecke rAdvanced" )):North52 .FormulaEd itor.Displ ayMessage( b);var h=p arent.Xrm. Page.data. entity.att ributes.ge t("north52 _shortcode ").getValu e();if(nul l!=h&&""!= h){var i=N 52.DialogH elpers.Get Configurat ionId(),k= (N52.Dialo gHelpers.G etServerUr l(),217890 019);try{v ar l={};l. north52_Co mmand={Val ue:k},l.no rth52_Comm andParamet er=h,SDK.J Query.upda teRecord(i ,l,"north5 2_configur ation",Nor th52.Formu laEditor.c onfigSucce ss,North52 .FormulaEd itor.confi gError)}ca tch(a){Nor th52.Formu laEditor.D isplayMess age("North 52 BPA Err or: "+a.me ssage)}}}, North52.Fo rmulaEdito r.DisplayM essage=fun ction(a){" undefined" ==typeof X rm.Page.ui .clearForm Notificati on?alert(a ):Xrm.Util ity.alertD ialog(a)}, North52.Fo rmulaEdito r.configSu ccess=func tion(){var  a="Advanc ed Syntax  check comp leted succ essfully"; "undefined "==typeof  parent.Xrm .Page.ui.c learFormNo tification ?North52.F ormulaEdit or.Display Message(a) :(parent.X rm.Page.ui .clearForm Notificati on("Syntax CheckerAdv anced"),pa rent.Xrm.P age.ui.set FormNotifi cation("Pa ssed - Adv anced form ula syntax  result.", "INFO","Sy ntaxChecke rAdvanced" ),setTimeo ut(North52 .FormulaEd itor.clear Messages,5 e3))},Nort h52.Formul aEditor.co nfigError= function(a ,b,c){var  d="Advance d formula  syntax res ult: "+a.m essage.rep lace("Erro r : 500: I nternal Se rver Error :","")+" * * Always c heck the h ighlighted  line and  the preced ing one fo r errors." ;"undefine d"==typeof  parent.Xr m.Page.ui. clearFormN otificatio n?North52. FormulaEdi tor.Displa yMessage(" North52 BP A:: "+d):( parent.Xrm .Page.ui.c learFormNo tification ("SyntaxCh eckerAdvan ced"),pare nt.Xrm.Pag e.ui.setFo rmNotifica tion(d,"IN FO","Synta xCheckerAd vanced")); var e=$(". CodeMirror ")[0].Code Mirror,f=p arseInt(d. substring( d.indexOf( "at line " )+8).split (":")[0])- 1,g=e.mark Text({line :f,ch:0},{ line:f,ch: 1e3},{clas sName:"sty led-backgr ound",clea rOnEnter:! 0});CodeMi rror.on(g, "clear",fu nction(){N orth52.For mulaEditor .clearMess ages()})}, North52.Fo rmulaEdito r.clearMes sages=func tion(){"un defined"!= typeof par ent.Xrm.Pa ge.ui.clea rFormNotif ication&&( parent.Xrm .Page.ui.c learFormNo tification ("SyntaxCh eckerBasic "),parent. Xrm.Page.u i.clearFor mNotificat ion("Synta xCheckerAd vanced"))} ,North52.F ormulaEdit or.RunComm and=functi on(){21789 0017==pare nt.Xrm.Pag e.data.ent ity.attrib utes.get(" north52_fo rmulatype" ).getValue ()?$("#dia logExecute Command"). wijdialog( "open"):No rth52.Form ulaEditor. DisplayMes sage("Only  formulas  of type Co mmand Cons ole can be  executed  here.")},N orth52.For mulaEditor .RunFuncti onWizard=f unction(){ $("#dialog FunctionWi zard").wij dialog("op en")},Nort h52.Formul aEditor.Cl ear=functi on(){if(1= =$("#formu la").is(": visible")) $(".CodeMi rror")[0]. CodeMirror .setValue( "");else{v ar a=$("#s s").data(" spread"),b =a.getActi veSheet(), c=b.getAct iveRowInde x(),d=b.ge tActiveCol umnIndex() ;b.getCell (c,d).valu e(""),docu ment.getEl ementById( "formulabo x").value= "",window. fbxx.text( ""),1==c&& b.getCell( c+1,d).val ue("")}},N orth52.For mulaEditor .Case=func tion(){Nor th52.Formu laEditor.I nsertTextA tCursor("C ase([accou nt.name],  \n\n  When ('Microsof t'), Then  ('Fantasti c'),\n\n   When('Nort h52'), The n ('Great' ),\n\n  De fault('Not  Microsoft  or North5 2')\n\n)", "")},North 52.Formula Editor.If= function() {North52.F ormulaEdit or.InsertT extAtCurso r("if(expr ession, tr ue, false) ","")},Nor th52.Formu laEditor.I fTrue=func tion(){Nor th52.Formu laEditor.I nsertTextA tCursor("i ftrue(expr ession, tr ue)","")}, North52.Fo rmulaEdito r.ResizeSS =function( ){$("#ss") .wijspread ("refresh" )},North52 .FormulaEd itor.And=f unction(){ North52.Fo rmulaEdito r.InsertTe xtAtCursor ("and","") },North52. FormulaEdi tor.Or=fun ction(){No rth52.Form ulaEditor. InsertText AtCursor(" or","")},N orth52.For mulaEditor .DoLoop=fu nction(){N orth52.For mulaEditor .InsertTex tAtCursor( "DoLoop( 3 , \n\n          Creat eRecord('t ask', \n          1,  \n          SetAttrib ute('subje ct', 'Task :' + DoLoo pIndex())) \n\n)","") },North52. FormulaEdi tor.ForEac hRecord=fu nction(){N orth52.For mulaEditor .InsertTex tAtCursor( "ForEachRe cord(\n\n           F indRecords ('account' , 'descrip tion', 'no rth52', '* '), \n\n           Up dateRecord ('account' ,\n                          Cur rentRecord ('accounti d'),\n                            SetAttrib ute('descr iption', ' Updated: '  + UtcDate Time()))\n )","")},No rth52.Form ulaEditor. SmartFlow= function() {North52.F ormulaEdit or.InsertT extAtCurso r("SmartFl ow(\n\n    SetVar('x' , 1), \n    SetVar('y ', 2),\n    SetVar('z ', 3 + Get Var('x') ) , \n\n   S martFlowRe turn( GetV ar('x') +  GetVar('y' ) + GetVar ('z') )\n) ","")},Nor th52.Formu laEditor.N oOp=functi on(){North 52.Formula Editor.Ins ertTextAtC ursor("'No Op'","")}, North52.Fo rmulaEdito r.Comment= function() {North52.F ormulaEdit or.InsertT extAtCurso r("/* */", "")},North 52.Formula Editor.Loa dSource=fu nction(a){ North52.Fo rmulaEdito r.ClearNod es("#trees ource");va r b=$("#tr eesource") .wijtree(" findNodeBy Text","Sou rce");b.el ement.wijt reenode("a dd",{text: "Loading.. .",params: "Loading.. ."},0);var  c=parent. Xrm.Page.d ata.entity .attribute s.get("nor th52_sourc eentitynam e").getVal ue();null! =a&&(c=a), SDK.Metada ta.Retriev eEntity(SD K.Metadata .EntityFil ters.Attri butes,c,nu ll,!1,func tion(a){No rth52.Form ulaEditor. successRet rieveAttri butes(a,c, "#treesour ce","Sourc e",!0)},No rth52.Form ulaEditor. errorRetri eveAttribu tes)},Nort h52.Formul aEditor.su ccessRetri eveAttribu tes=functi on(a,b,c,d ,e){var f= $(c).wijtr ee("findNo deByText", d),g=null; 1==e&&Nort h52.Formul aEditor.Cl earNodes(c );for(var  h=0;h<a.At tributes.l ength;h++) {var i=a.A ttributes[ h];if(null !=i.Displa yName.User LocalizedL abel&&null !=i.Displa yName.User LocalizedL abel.Label ){if(g="Pi cklist"==i .Attribute Type?i.Dis playName.U serLocaliz edLabel.La bel+" {Val ue}":"Look up"==i.Att ributeType ?i.Display Name.UserL ocalizedLa bel.Label+ " (Value)" :"Boolean" ==i.Attrib uteType?i. DisplayNam e.UserLoca lizedLabel .Label+" ( Value)":i. DisplayNam e.UserLoca lizedLabel .Label,f.e lement.wij treenode(" add",{tool Tip:i.Attr ibuteType, text:g,par ams:"["+a. LogicalNam e+"."+a.At tributes[h ].LogicalN ame+"]"},0 ),"Status" ==i.Attrib uteType||" State"==i. AttributeT ype)for(va r j=0;j<i. OptionSet. Options.le ngth;j++)f .getNodes( )[0].eleme nt.wijtree node("add" ,{toolTip: i.Attribut eType,text :i.OptionS et.Options [j].Label. UserLocali zedLabel.L abel,param s:" "+i.Op tionSet.Op tions[j].V alue},0);i f("Boolean "==i.Attri buteType&& (f.getNode s()[0].ele ment.wijtr eenode("ad d",{toolTi p:i.Attrib uteType,te xt:i.Optio nSet.False Option.Lab el.UserLoc alizedLabe l.Label,pa rams:" "+i .OptionSet .FalseOpti on.Value}, 0),f.getNo des()[0].e lement.wij treenode(" add",{tool Tip:i.Attr ibuteType, text:i.Opt ionSet.Tru eOption.La bel.UserLo calizedLab el.Label,p arams:" "+ i.OptionSe t.TrueOpti on.Value}, 0)),"Pickl ist"==i.At tributeTyp e||"Lookup "==i.Attri buteType|| "Boolean"= =i.Attribu teType){if ("Picklist "==i.Attri buteType){ for(var j= 0;j<i.Opti onSet.Opti ons.length ;j++)f.get Nodes()[0] .element.w ijtreenode ("add",{to olTip:i.At tributeTyp e,text:i.O ptionSet.O ptions[j]. Label.User LocalizedL abel.Label ,params:"  "+i.Option Set.Option s[j].Value },0);f.get Nodes()[0] .sortNodes ()}g="Pick list"==i.A ttributeTy pe?i.Displ ayName.Use rLocalized Label.Labe l+" {Name} ":i.Displa yName.User LocalizedL abel.Label +" (Name)" ,f.element .wijtreeno de("add",{ toolTip:i. AttributeT ype,text:g ,params:"[ "+a.Logica lName+"."+ a.Attribut es[h].Logi calName+"n ame]"},0)} }}f.sortNo des(),$("# refreshSou rce").attr ("src","no rth52_imag e_refresh" ),$("#refr eshExplore ").hide()} ,North52.F ormulaEdit or.LoadFor mulaDetail s=function (a,b){var  c=parent.X rm.Page.da ta.entity. getId();if (null!=c&& ""!=c&&(nu ll==b||"Qu ery Detail s"==b.node ._text)){$ ("#refresh Source").a ttr("src", "north52_i mage_progr ess");var  d="$select =north52_n ame,north5 2_Query&$f ilter=nort h52_formul a_north52_ formuladet ail_Id/Id  eq guid'"+ c+"' and n orth52_Que ryType/Val ue eq 2178 90000";SDK .REST.retr ieveMultip leRecords( "north52_f ormuladeta il",d,Nort h52.Formul aEditor.re trieveForm ulaDetailC allBack,fu nction(a){ North52.Fo rmulaEdito r.DisplayM essage("No rth52 Form ula Manage r: "+a.mes sage)},Nor th52.Formu laEditor.f ormsRetrie veComplete )}},North5 2.FormulaE ditor.retr ieveFormul aDetailCal lBack=func tion(a){va r b=$("#tr eedetail") .wijtree(" findNodeBy Text","Que ry Details ");North52 .FormulaEd itor.Clear Nodes("#tr eedetail") ,0==a.leng th&&b.elem ent.wijtre enode("add ",{text:"N o formula  details cr eated.",pa rams:""},0 );for(var  c=0;c<a.le ngth;c++){ var d=a[c] ,e=N52.HTM LWebResour ceHelper.G etXmlDocum ent(d.nort h52_Query) ,f=d.north 52_name;b. element.wi jtreenode( "add",{tex t:f,params :"'"+f+"'" },0);for(v ar g="/fet ch/entity/ attribute" ,h=N52.HTM LWebResour ceHelper.G etXmlNodes (e,g),i=0; i<h.length ;i++){var  j=h[i].att ributes[0] .value;b.g etNodes()[ 0].element .wijtreeno de("add",{ text:h[i]. attributes [0].value, params:"'" +j+"'"},0) }}$("#refr eshSource" ).attr("sr c","north5 2_image_re fresh")},N orth52.For mulaEditor .LoadForms =function( ){$("#refr eshSource" ).attr("sr c","north5 2_image_pr ogress");v ar a="",b= parent.Xrm .Page.data .entity.at tributes.g et("north5 2_sourceen tityname") .getValue( );North52. FormulaEdi tor.ClearN odes("#tre eforms"),a ="undefine d"!=typeof  parent.Xr m.Page.ui. clearFormN otificatio n?"$select =Name,Form Xml&$filte r=ObjectTy peCode eq  '"+b+"' an d (Type/Va lue eq 2 o r Type/Val ue eq 7) a nd FormAct ivationSta te/Value e q 1":"$sel ect=Name,F ormXml&$fi lter=Objec tTypeCode  eq '"+b+"'  and Type/ Value eq 2 ",SDK.REST .retrieveM ultipleRec ords("Syst emForm",a, North52.Fo rmulaEdito r.retrieve FormCallBa ck,functio n(a){North 52.Formula Editor.Dis playMessag e("North52  Formula M anager: "+ a.message) },North52. FormulaEdi tor.formsR etrieveCom plete)},No rth52.Form ulaEditor. retrieveFo rmCallBack =function( a){var b=$ ("#treefor ms").wijtr ee("findNo deByText", "Forms"),c =null;Nort h52.Formul aEditor.Cl earNodes(" #treeforms ");for(var  d=0;d<a.l ength;d++) {var e=a[d ];b.elemen t.wijtreen ode("add", {text:e.Na me,params: e.Name},0) ;for(var f =N52.HTMLW ebResource Helper.Get XmlDocumen t(e.FormXm l),g="/for m/tabs/tab ",h=N52.HT MLWebResou rceHelper. GetXmlNode s(f,g),i=0 ;i<h.lengt h;i++){var  j=h[i],k= "'"+$.map( j.attribut es,functio n(a){retur n"name"==a .name?a.no deValue:nu ll})+"'",c =j.childNo des[0].chi ldNodes[0] .attribute s[0].nodeV alue;b.get Nodes()[0] .element.w ijtreenode ("add",{te xt:c,param s:k},i);fo r(var l=0; l<j.childN odes.lengt h;l++)for( var m=j.ch ildNodes[l ],n=0;n<m. childNodes .length;n+ +)for(var  o=m.childN odes[n],p= 0;p<o.chil dNodes.len gth;p++)fo r(var q=o. childNodes [p],r=0;r< q.childNod es.length; r++){var s =q.childNo des[r];if( "Handler"! =s.nodeNam e){k="'"+$ .map(s.att ributes,fu nction(a){ return"nam e"==a.name ?a.nodeVal ue:null})+ "'",c=s.ch ildNodes[0 ].childNod es[0].attr ibutes[0]. nodeValue, b.getNodes ()[0].getN odes()[i]. element.wi jtreenode( "add",{tex t:c,params :k},r);for (var t=1;t <s.childNo des.length ;t++)for(v ar u=s.chi ldNodes[t] ,v=0;v<u.c hildNodes. length;v++ )for(var w =u.childNo des[v],x=0 ;x<w.child Nodes.leng th;x++){va r y=w.chil dNodes[x]; y.childNod es.length< 2||(k=0!=y .childNode s[1].attri butes.leng th?y.child Nodes[1].a ttributes[ 0].nodeVal ue:y.child Nodes[2].a ttributes[ 0].nodeVal ue,c=y.chi ldNodes[0] .childNode s[0].attri butes[0].n odeValue,b .getNodes( )[0].getNo des()[i].g etNodes()[ r].element .wijtreeno de("add",{ text:c,par ams:"'"+k+ "'"},t))}} }}}b.sortN odes(),$(" #refreshSo urce").att r("src","n orth52_ima ge_refresh ")},North5 2.FormulaE ditor.form sRetrieveC omplete=fu nction(){} ,North52.F ormulaEdit or.Populat eTreeExplo re=functio n(a){$("#r efreshExpl ore").show (),North52 .FormulaEd itor.Clear Nodes("#tr eeexplore" );var b=$( "#treeexpl ore").wijt ree("findN odeByText" ,a),c="Ent ityList52" +parent.Xr m.Page.con text.getOr gUniqueNam e(),d=JSON .parse(loc alStorage. getItem(c) );if(null! =d){for(va r e=0;e<d. length;e++ ){var f=d[ e].split(" |"),g=f[0] ,h=f[1];b. element.wi jtreenode( "add",{has Children:! 0,params:" '"+h+"'",t ext:g,coll apsedIconC lass:"ui-i con-folder -collapsed ",expanded IconClass: "ui-icon-f older-open "},0)}b.so rtNodes(), $("#refres hExplore") .hide()}}, North52.Fo rmulaEdito r.ClearNod es=functio n(a){var b =$(a).find ("li");$.e ach(b,func tion(a,b){ var c=$(b) .wijtreeno de("getOwn er"),d=$(b ).index(); null!=c?c. element.wi jtreenode( "remove",d ):$(b).wij treenode(" remove",d) })},North5 2.FormulaE ditor.Refr eshSource= function() {$("#refre shSource") .attr("src ","north52 _image_pro gress"),No rth52.Form ulaEditor. LoadFormul aDetails(n ull,null), North52.Fo rmulaEdito r.LoadForm s(),North5 2.FormulaE ditor.Load Source(),N orth52.For mulaEditor .ClearNode s("#treere lated");va r a=$("#tr eerelated" ).wijtree( "findNodeB yText","Re lated (N:1 )");a.elem ent.wijtre enode("add ",{text:"L oading..." },0),North 52.Formula Editor.Loa dRelated(n ull,null), North52.Fo rmulaEdito r.BuildTre es("Calcul ations"),N orth52.For mulaEditor .BuildTree s("Actions ")},North5 2.FormulaE ditor.Expl oreGenerat or=functio n(){var a= "",b="",c= "",d="",e= $("#treeex plore").wi jtree("get CheckedNod es");if(0= =e.length) return voi d North52. FormulaEdi tor.Displa yMessage(" North52: Y ou must ch eck some f ield names  before th e generato r will run .");$(e).e ach(functi on(c,d){"" ==a&&(a=$( this).wijt reenode("g etOwner"). _text,b=$( this).wijt reenode("g etOwner"). options.pa rams)});va r f=$("#ex ploregener ator").fin d(":select ed").text( );if("Crea teRecord"= =f)c=Strin g.format(" {0}('{1}',  \nXXX\n ) ",f,b.repl ace("'","" ).replace( "'",""));e lse if("Up dateRecord "==f||"Upd ateCreateR ecord"==f) c=String.f ormat("{0} ('{1}',\n               [{1}.{1} id],\nXXX\ n  )",f,b. replace("' ","").repl ace("'","" ));else if ("JSON"==f )c="Create JObject(\n XXX           )";else {if("XML"! =f)return; c=String.f ormat("Cre ateXmlRoot Node('{0}' , '', '',  \nXXX           )",a) }for(var g =$("#treee xplore").w ijtree("fi ndNodeByTe xt",a),h=g .getNodes( ),i=0;i<h. length;i++ )if("check ed"==h[i]. options.ch eckState){ var j=h[i] .options.p arams.repl ace("]","" );j=j.spli t(".")[1], d="JSON"== f?String.f ormat("             C reateJProp erty('{0}' , {1}),",h [i]._text, h[i].optio ns.params) :"XML"==f? String.for mat("                    CreateX mlElement( '{0}', {1} ),",h[i]._ text,h[i]. options.pa rams):"Loo kup"==h[i] .options.t oolTip||"C ustomer"== h[i].optio ns.toolTip ?String.fo rmat("              S etAttribut eLookup('{ 0}', 'enti tylogicaln ame' ,'val ue'),",j): "statecode "==j||"sta tuscode"== j?String.f ormat("               SetAttribu teStatus(' statecode' , 'statusc ode'),",j) :String.fo rmat("              S etAttribut e('{0}', ' value'),", j),c=c.rep lace("XXX" ,d+"\nXXX" )}c=c.repl ace("XXX", ""),c=c.re place(d,d. substr(0,d .length-1) ),North52. FormulaEdi tor.Insert TextAtCurs or(c,c)},N orth52.For mulaEditor .LoadRelat ed=functio n(a,b){var  c=null;if (c=null==b ?$("#treer elated").w ijtree("fi ndNodeByTe xt","Relat ed (N:1)") :b.node,!( c.getNodes ().length> =1&&"Loadi ng..."!=c. getNodes() [0]._text) ){var d=pa rent.Xrm.P age.data.e ntity.attr ibutes.get ("north52_ sourceenti tyname").g etValue(), e=parent.X rm.Page.da ta.entity. attributes .get("nort h52_source entityname ").getValu e();null!= c.options& &null!=c.o ptions.too lTip&&""!= c.options. toolTip&&( d=c.option s.toolTip) ,null!=c.o ptions&&nu ll!=c.opti ons.text&& "(Attribut es)"==c.op tions.text ?SDK.Metad ata.Retrie veEntity(S DK.Metadat a.EntityFi lters.Attr ibutes,d,n ull,!1,fun ction(a){N orth52.For mulaEditor .successRe trieveAttr ibutesEx(a ,d,"#treer elated","R elated (N: 1)",!0,c,e )},North52 .FormulaEd itor.error RetrieveAt tributes): SDK.Metada ta.Retriev eEntity(SD K.Metadata .EntityFil ters.Relat ionships,d ,null,!1,f unction(a) {North52.F ormulaEdit or.success RetrieveRe lated(a,d, "#treerela ted","Rela ted (N:1)" ,!0,c,e)}, North52.Fo rmulaEdito r.errorRet rieveAttri butes)}},N orth52.For mulaEditor .successRe trieveAttr ibutesEx=f unction(a, b,c,d,e,f, g){var h=" ",i=f.getO wner();if( !(f.getNod es().lengt h>1)){for( ;;){if(nul l==i||"Rel ated (N:1) "==i.optio ns.text)br eak;h=i.op tions.text .replace(" (","").rep lace(")"," ").split("  ")[1]+"." +h,i=i.get Owner()}fo r(var j=0; j<a.Attrib utes.lengt h;j++){var  k=a.Attri butes[j];i f(null!=k. DisplayNam e.UserLoca lizedLabel &&null!=k. DisplayNam e.UserLoca lizedLabel .Label){if ("Picklist "==k.Attri buteType?d isplayText =k.Display Name.UserL ocalizedLa bel.Label+ " {Value}" :"Lookup"= =k.Attribu teType?dis playText=k .DisplayNa me.UserLoc alizedLabe l.Label+"  (Value)":" Boolean"== k.Attribut eType?disp layText=k. DisplayNam e.UserLoca lizedLabel .Label+" ( Value)":di splayText= k.DisplayN ame.UserLo calizedLab el.Label,f .element.w ijtreenode ("add",{to olTip:k.At tributeTyp e,text:dis playText,p arams:"["+ g+"."+h+a. Attributes [j].Logica lName+".?] "},0),"Sta tus"==k.At tributeTyp e||"State" ==k.Attrib uteType)fo r(var l=0; l<k.Option Set.Option s.length;l ++)f.getNo des()[0].e lement.wij treenode(" add",{tool Tip:k.Attr ibuteType, text:k.Opt ionSet.Opt ions[l].La bel.UserLo calizedLab el.Label,p arams:" "+ k.OptionSe t.Options[ l].Value}, 0);if("Boo lean"==k.A ttributeTy pe&&(f.get Nodes()[0] .element.w ijtreenode ("add",{to olTip:k.At tributeTyp e,text:k.O ptionSet.F alseOption .Label.Use rLocalized Label.Labe l,params:"  "+k.Optio nSet.False Option.Val ue},0),f.g etNodes()[ 0].element .wijtreeno de("add",{ toolTip:k. AttributeT ype,text:k .OptionSet .TrueOptio n.Label.Us erLocalize dLabel.Lab el,params: " "+k.Opti onSet.True Option.Val ue},0)),"P icklist"== k.Attribut eType||"Lo okup"==k.A ttributeTy pe||"Boole an"==k.Att ributeType ){if("Pick list"==k.A ttributeTy pe){for(va r l=0;l<k. OptionSet. Options.le ngth;l++)f .getNodes( )[0].eleme nt.wijtree node("add" ,{toolTip: k.Attribut eType,text :k.OptionS et.Options [l].Label. UserLocali zedLabel.L abel,param s:" "+k.Op tionSet.Op tions[l].V alue},0);f .getNodes( )[0].sortN odes()}"Pi cklist"==k .Attribute Type?displ ayText=k.D isplayName .UserLocal izedLabel. Label+" {N ame}":disp layText=k. DisplayNam e.UserLoca lizedLabel .Label+" ( Name)",f.e lement.wij treenode(" add",{tool Tip:k.Attr ibuteType, text:displ ayText,par ams:"["+a. LogicalNam e+"."+a.At tributes[j ].LogicalN ame+"name] "},0)}}}f. sortNodes( )}},North5 2.FormulaE ditor.succ essRetriev eRelated=f unction(a, b,c,d,e,f, g){var h=" ",i=f.getO wner();if( !(f.getNod es().lengt h>1)){for( "Related ( N:1)"==f.o ptions.tex t?f.elemen t.wijtreen ode("remov e",0):(h=f .options.t ext.replac e("(",""). replace(") ","").spli t(" ")[1]+ ".",f.elem ent.wijtre enode("rem ove",0),f. element.wi jtreenode( "add",{too lTip:f.opt ions.toolT ip,text:"( Attributes )"},0),f.g etNodes()[ 0].element .wijtreeno de("add",{ toolTip:f. options.to olTip,text :"Loading. .."},0));; ){if(null= =i||"Relat ed (N:1)"= =i.options .text)brea k;h=i.opti ons.text.r eplace("(" ,"").repla ce(")","") .split(" " )[1]+"."+h ,i=i.getOw ner()}if(n ull!=a.Man yToOneRela tionships) for(var j= 0;j<a.Many ToOneRelat ionships.l ength;j++) {var k=a.M anyToOneRe lationship s[j],l=k.R eferencedE ntity,m=k. Referencin gAttribute ;text=l+"  ("+m+")";f .getOwner( );f.elemen t.wijtreen ode("add", {toolTip:k .Reference dEntity,te xt:text,pa rams:"["+g +"."+h+k.R eferencing Attribute+ ".?]"},0), f.getNodes ()[0].elem ent.wijtre enode("add ",{toolTip :k.Referen cedEntity, text:"Load ing..."},0 ),f.getNod es()[0].ge tNodes()[0 ].element. wijtreenod e("add",{t oolTip:k.R eferencedE ntity,text :"Loading. .."},0)}f. sortNodes( ),North52. FormulaEdi tor.ClearN odes("#tre erelatednn ");var o=$ ("#treerel atednn").w ijtree("fi ndNodeByTe xt","Relat ed (N:N)") ;if(null!= a.ManyToMa nyRelation ships)for( var j=0;j< a.ManyToMa nyRelation ships.leng th;j++){va r k=a.Many ToManyRela tionships[ j],l=k.Ent ity1Logica lName,m=k. IntersectE ntityName; text=l+" ( "+m+")",o. element.wi jtreenode( "add",{too lTip:k.Sch emaName,te xt:text,pa rams:"'"+k .SchemaNam e+"'"},0)} o.sortNode s()}},Nort h52.Formul aEditor.re trievePrim aryIdAttri bute=funct ion(a,b){f or(var c=b ,d="Entity List52"+pa rent.Xrm.P age.contex t.getOrgUn iqueName() ,e=JSON.pa rse(localS torage.get Item(d)),f =0;f<e.len gth;f++){v ar g=e[f]. split("|") ;if(!(g.le ngth<2)){v ar i=(g[0] ,g[1]),j=g [3];if(c=j ,a==i)brea k}}return  c},North52 .FormulaEd itor.error RetrieveAt tributes=f unction(a) {North52.F ormulaEdit or.Display Message("N orth52 For mula Manag er : "+a.m essage)},N orth52.For mulaEditor .LoadxCach e=function (){var a=" $select=no rth52_name ,north52_C ategory&$o rderby=nor th52_Categ ory,north5 2_name";SD K.REST.ret rieveMulti pleRecords ("north52_ xcache",a, North52.Fo rmulaEdito r.retrieve xCacheCall Back,funct ion(a){Nor th52.Formu laEditor.D isplayMess age("North 52 Formula  Manager:  "+a.messag e)},North5 2.FormulaE ditor.form sRetrieveC omplete)}, North52.Fo rmulaEdito r.retrieve xCacheCall Back=funct ion(a){var  b=$("#tre excache"). wijtree("f indNodeByT ext","xCac he");North 52.Formula Editor.Cle arNodes("# treexcache "),0==a.le ngth&&b.el ement.wijt reenode("a dd",{text: "No xCache  records f ound.",par ams:""},0) ;for(var c =0;c<a.len gth;c++){v ar d=a[c], e=$("#tree xcache").w ijtree("fi ndNodeByTe xt",d.nort h52_name), f=$("#tree xcache").w ijtree("fi ndNodeByTe xt",d.nort h52_Catego ry);null== f&&b.eleme nt.wijtree node("add" ,{text:d.n orth52_Cat egory,para ms:""}),nu ll==e&&(f= $("#treexc ache").wij tree("find NodeByText ",d.north5 2_Category ),f.elemen t.wijtreen ode("add", {text:d.no rth52_name ,params:"{ {"+d.north 52_name+"} }"}))}b.so rtNodes()} ,North52.F ormulaEdit or.LoadPro cesses=fun ction(){va r a="$sele ct=Name,Ca tegory&$or derby=Cate gory,Name& $filter=Ty pe/Value e q 1 and St ateCode/Va lue eq 1 a nd (Catego ry/Value e q 0 or Cat egory/Valu e eq 1 or  Category/V alue eq 3  or Categor y/Value eq  4)";SDK.R EST.retrie veMultiple Records("W orkflow",a ,North52.F ormulaEdit or.retriev eProcesses CallBack,f unction(a) {North52.F ormulaEdit or.Display Message("N orth52 For mula Manag er: "+a.me ssage)},No rth52.Form ulaEditor. formsRetri eveComplet e)},North5 2.FormulaE ditor.retr ieveProces sesCallBac k=function (a){North5 2.FormulaE ditor.Clea rNodes("#t reeprocess es");var b =$("#treep rocesses") .wijtree(" findNodeBy Text","Pro cesses"),c =["Workflo ws","Dialo gs","UnKno wn","Actio ns","Busin ess Flows" ];0==a.len gth&&b.ele ment.wijtr eenode("ad d",{text:" No Process es records  found.",p arams:""}, 0);for(var  d=0;d<a.l ength;d++) {var e=a[d ],f=$("#tr eeprocesse s").wijtre e("findNod eByText",e .Name),g=$ ("#treepro cesses").w ijtree("fi ndNodeByTe xt",c[e.Ca tegory.Val ue]);null= =g&&b.elem ent.wijtre enode("add ",{text:c[ e.Category .Value],pa rams:""}), null==f&&( g=$("#tree processes" ).wijtree( "findNodeB yText",c[e .Category. Value]),g. element.wi jtreenode( "add",{tex t:e.Name,p arams:"'"+ e.Name+"'" }))}b.sort Nodes()},N orth52.For mulaEditor .BuildTree s=function (a){var b= $("#ss").d ata("sprea d"),c=b.ge tSheetFrom Name(a);if ("Calculat ions"==a){ null!=c.ge tValue(1,0 )&&North52 .FormulaEd itor.Clear Nodes("#tr eecalculat ions");for (var d=$(" #treecalcu lations"). wijtree("f indNodeByT ext","Calc ulations") ,e=1;e<=10 0&&null!=c .getValue( e,0)&&null !=c.getVal ue(e,1);e+ +){var f=c .getValue( e,0),g=Str ing.format ("GetVar(' {0}')",f); d.element. wijtreenod e("add",{t ext:f,para ms:g},0)}N orth52.For mulaEditor .ClearNode s("#treede cisioncalc ulations") ,b.sheets. forEach(fu nction(a){ if("Action s"!=a.getN ame()&&"Ca lculations "!=a.getNa me()&&"Con figuration "!=a.getNa me()){var  b=[],b=Nor th52.Formu laEditor.G etAllCalcs (a,b,0,"== ");b=North 52.Formula Editor.Get AllCalcs(a ,b,0,"+=") ,b=North52 .FormulaEd itor.GetAl lCalcs(a,b ,0,"-="),b .forEach(f unction(a) {var b=Str ing.format ("GetVar(' {0}')",a), c=$("#tree decisionca lculations ").wijtree ("findNode ByText","D ecision Ta ble Calcul ations");c .element.w ijtreenode ("add",{te xt:a,param s:b},0)})} }),North52 .FormulaEd itor.Injec tNoneFound Node("#tre ecalculati ons","Calc ulations") ,North52.F ormulaEdit or.InjectN oneFoundNo de("#treed ecisioncal culations" ,"Decision  Table Cal culations" )}else if( "Actions"= =a){null!= c.getValue (1,0)&&Nor th52.Formu laEditor.C learNodes( "#treeacti ons");for( var e=1;e< =100&&null !=c.getVal ue(e,0)&&n ull!=c.get Value(e,1) ;e++){var  f=c.getVal ue(e,0),g= ""+e,h=$(" #treeactio ns").wijtr ee("findNo deByText", "Actions") ;h.element .wijtreeno de("add",{ text:f,par ams:g},0)} }},North52 .FormulaEd itor.GetAl lCalcs=fun ction(a,b, c,d){var e =new GcSpr ead.Sheets .SearchCon dition;e.s earchStrin g=d,e.rowS tart=2,e.r owEnd=2,e. columnStar t=c;var f= a.search(e );if(f.sea rchFoundFl ag!=GcSpre ad.Sheets. SearchFoun dFlags.Non e){var g=a .getValue( 1,f.foundC olumnIndex );c=f.foun dColumnInd ex+1,null! =g&&(b.pus h(g),b=Nor th52.Formu laEditor.G etAllCalcs (a,b,c))}r eturn b},N orth52.For mulaEditor .InjectNon eFoundNode =function( a,b){0==$( a).wijtree ("findNode ByText",b) .getNodes( ).length&& $(a).wijtr ee("findNo deByText", b).element .wijtreeno de("add",{ text:"None  Found.",p arams:""}, 0)},North5 2.FormulaE ditor.Inje ctHyperLin kHelp=func tion(){$(" span.helpI d").each(f unction(){ var a=$(th is).text() .split("(" )[0];$(thi s).attr("t itle",$(th is).attr(" title")+"< br></br><b r></br><a  target='_b lank' styl e='color:  White' hre f='http:// support.no rth52.com/ search?fil ter=articl es&query=" +a+"'>Sear ch Online  KB Article s</a>")})} ,North52.F ormulaEdit or.ToggleA ccordionMo de=functio n(a,b){nul l!=a&&a.ct rlKey===!0 &&$("#acco rdion").wi jaccordion ("option", "requireOp enedPane", !0)},North 52.Formula Editor.Fin dCurrentTa g=function (a,b){var  c="true";r eturn c=b= =-1?a.tag( ):a.tag(). split("|") [b]},North 52.Formula Editor.Set CurrentTag =function( a,b,c){var  d=a.tag() .split("|" );d[b]=c,a .tag(d.joi n("|"))},N orth52.For mulaEditor .EventsIni t=function (){$("#tre esource"). wijtree({n odeClick:f unction(a, b){try{eve nt.ctrlKey ===!0&&b.o ptions.par ams.split( ".").lengt h>0?North5 2.FormulaE ditor.Inse rtTextAtCu rsor(b.opt ions.text, "'"+b.opti ons.params .split("." )[1].slice (0,-1)+"'" ,this.id,b .options.t oolTip):No rth52.Form ulaEditor. InsertText AtCursor(b .options.t ext,b.opti ons.params ,this.id,b .options.t oolTip)}ca tch(a){Nor th52.Formu laEditor.I nsertTextA tCursor(b. options.te xt,b.optio ns.params, this.id,b. options.to olTip)}}}) ,$("#treer elated").w ijtree({no deClick:fu nction(a,b ){North52. FormulaEdi tor.Insert TextAtCurs or(b.optio ns.text,b. options.pa rams,this. id,b.optio ns.toolTip )}}),$("#t reerelated nn").wijtr ee({nodeCl ick:functi on(a,b){No rth52.Form ulaEditor. InsertText AtCursor(b .options.t ext,b.opti ons.params )}}),$("#t reedetail" ).wijtree( {nodeClick :function( a,b){North 52.Formula Editor.Ins ertTextAtC ursor(b.op tions.text ,b.options .params)}} ),$("#tree explore"). wijtree({n odeClick:f unction(a, b){event.c trlKey===! 0&&b.optio ns.params. split(".") .length>0? North52.Fo rmulaEdito r.InsertTe xtAtCursor (b.options .text,"'"+ b.options. params.spl it(".")[1] .slice(0,- 1)+"'"):No rth52.Form ulaEditor. InsertText AtCursor(b .options.t ext,b.opti ons.params ,b.options .params,th is.id,b.op tions.tool Tip)}}),$( "#treefunc tions").wi jtree({nod eClick:fun ction(a,b) {0==b._has Children&& North52.Fo rmulaEdito r.InsertTe xtAtCursor (b._text,b ._text,thi s.id,b.opt ions.toolT ip)}}),$(" #treeforms ").wijtree ({nodeClic k:function (a,b){Nort h52.Formul aEditor.In sertTextAt Cursor(b.o ptions.tex t,b.option s.params)} }),$("#tre ecalculati ons").wijt ree({nodeC lick:funct ion(a,b){N orth52.For mulaEditor .InsertTex tAtCursor( b.options. text,b.opt ions.param s,this.id, b.options. toolTip)}} ),$("#tree decisionca lculations ").wijtree ({nodeClic k:function (a,b){Nort h52.Formul aEditor.In sertTextAt Cursor(b.o ptions.tex t,b.option s.params,t his.id,b.o ptions.too lTip)}}),$ ("#treeact ions").wij tree({node Click:func tion(a,b){ North52.Fo rmulaEdito r.InsertTe xtAtCursor (b.options .text,b.op tions.text ,this.id,b .options.t oolTip)}}) ,$("#treex cache").wi jtree({nod eClick:fun ction(a,b) {var c=b.o ptions.tex t,d=b.opti ons.params ;1==$("#fo rmula").is (":visible ")&&"{{"== d.substrin g(0,2)&&(d =String.fo rmat("xCac heGetGloba l('{0}')", d.replace( "{{","").r eplace("}} ",""))),No rth52.Form ulaEditor. InsertText AtCursor(c ,d)}}),$(" #treeproce sses").wij tree({node Click:func tion(a,b){ 0==b._hasC hildren&&N orth52.For mulaEditor .InsertTex tAtCursor( b.options. text,b.opt ions.param s)}}),$("# flyoutmenu ").wijmenu ({ensureSu bmenuOnBod y:!0,trigg er:".wijmo -wijmenu-i tem",trigg erEvent:"c lick",sele ct:functio n(a,b){"Sn ippets"!=b .item.opti ons.text&& "Operators "!=b.item. options.te xt&&"Comma nds"!=b.it em.options .text&&("C ase"==b.it em.options .text?Nort h52.Formul aEditor.Ca se():"If"= =b.item.op tions.text ?North52.F ormulaEdit or.If():"I fTrue"==b. item.optio ns.text?No rth52.Form ulaEditor. IfTrue():" DoLoop"==b .item.opti ons.text?N orth52.For mulaEditor .DoLoop(): "ForEachRe cord"==b.i tem.option s.text?Nor th52.Formu laEditor.F orEachReco rd():"Smar tFlow"==b. item.optio ns.text?No rth52.Form ulaEditor. SmartFlow( ):"NoOp"== b.item.opt ions.text? North52.Fo rmulaEdito r.NoOp():" Comment"== b.item.opt ions.text? North52.Fo rmulaEdito r.Comment( ):"And"==b .item.opti ons.text?N orth52.For mulaEditor .And():"Or "==b.item. options.te xt?North52 .FormulaEd itor.Or(): "Toggle Ed itor"==b.i tem.option s.text?Nor th52.Formu laEditor.T oggleDecis ionTableMo de():North 52.Formula Editor.Ins ertTextAtC ursor(b.it em.options .text,b.it em.options .text));
        3   }}),$("#co ntextMenu" ).wijmenu( {trigger:" #ss",trigg erEvent:"r tclick",or ientation: "vertical" ,select:fu nction(a,b ){var c=b. item.optio ns,d=$("#s s").data(" spread"),e =d.getActi veSheet(), g=(GcSprea d.Sheets,e .getSelect ions());sw itch(c.tex t.trim()){ case"Cut": GcSpread.S heets.Spre adActions. cut.call(e );break;ca se"Copy":i f(event.ct rlKey===!0 ){var d=$( "#ss").wij spread("sp read");"Ac tions"!=d. getActiveS heet().get Name()&&"C alculation s"!=d.getA ctiveSheet ().getName ()&&(sheet To=North52 .FormulaEd itor.SubDT (),sheetTo .fromJSON( e.toJSON() ))}else Gc Spread.She ets.Spread Actions.co py.call(e) ;break;cas e"Paste":G cSpread.Sh eets.Sprea dActions.p aste.call( e);break;c ase"Insert  Row":for( var h=g[0] .row;h<g[0 ].row+g[0] .rowCount; h++)e.addR ows(h+g[0] .rowCount, 1);break;c ase"Insert  Condition ":for(var  h=g[0].col ;h<g[0].co l+g[0].col Count;h++) e.addColum ns(h+g[0]. colCount,1 ),e.getCel l(0,h+g[0] .colCount) .value("Co ndition"), e.getCell( 0,h+g[0].c olCount).b ackColor(" #ffdf80"), e.getCell( 0,h+g[0].c olCount).f ont("itali c 9pt aria l"),e.getC ell(1,h+g[ 0].colCoun t).font("b old 10pt a rial"),e.g etCell(1,h +g[0].colC ount).back Color("#ff df80"),e.g etCell(1,h +g[0].colC ount).word Wrap(!0),e .getCell(2 ,h+g[0].co lCount).ba ckColor("# ffdf80"),e .setColumn Width(h+g[ 0].colCoun t,120,GcSp read.Sheet s.SheetAre a.viewport ),e.getCol umn(h+g[0] .colCount) .hAlign(Gc Spread.She ets.Horizo ntalAlign. left);brea k;case"Ins ert Action ":for(var  i=0;i<=100 ;i++){var  j=String(e .getValue( 0,i));if(n ull==j||"n ull"==j){e .addColumn s(i,1),e.g etCell(0,i ).value("A ction"),e. getCell(0, i).backCol or("#80c78 4"),e.getC ell(0,i).f ont("itali c 9pt aria l"),e.getC ell(1,i).f ont("bold  10pt arial "),e.getCe ll(1,i).ba ckColor("# 80c784"),e .getCell(1 ,i).wordWr ap(!0),e.g etCell(2,i ).backColo r("#80c784 "),e.setCo lumnWidth( i,120,GcSp read.Sheet s.SheetAre a.viewport ),e.getCol umn(i).hAl ign(GcSpre ad.Sheets. Horizontal Align.left );break}}b reak;case" Insert Dec ision Shee t":North52 .FormulaEd itor.SubDT ();break;c ase"Toggle  Formula B ox":North5 2.FormulaE ditor.Togg leFormulaB ox();break ;case"Togg le Column  Or":North5 2.FormulaE ditor.Togg leColumnOr ();break;c ase"Delete  Row":for( var h=g[0] .row;h<g[0 ].row+g[0] .rowCount; h++)e.dele teRows(g[0 ].row,1);b reak;case" Delete Col umn":for(v ar h=g[0]. col;h<g[0] .col+g[0]. colCount;h ++)e.delet eColumns(g [0].col,1) ;break;cas e"Delete S heet":var  d=$("#ss") .wijspread ("spread") ;"Actions" !=d.getAct iveSheet() .getName() &&"Calcula tions"!=d. getActiveS heet().get Name()&&d. getSheetCo unt()>3&&d .removeShe et(d.getAc tiveSheetI ndex());br eak;case"T oggle Adva nced Mode" :North52.F ormulaEdit or.ToggleD TAdvancedM ode();brea k;case"Exi t this Dec ision Tabl e on First  Match":va r k=$("#ss ").data("s pread").ge tActiveShe et();"fals e"==North5 2.FormulaE ditor.Find CurrentTag (k,0)?Nort h52.Formul aEditor.Se tCurrentTa g(k,0,"tru e"):North5 2.FormulaE ditor.SetC urrentTag( k,0,"false ");break;c ase"Exit A ll Decisio n Tables o n First Ma tch":var k =$("#ss"). data("spre ad").getAc tiveSheet( );"false"= =North52.F ormulaEdit or.FindCur rentTag(k, 1)?North52 .FormulaEd itor.SetCu rrentTag(k ,1,"true") :North52.F ormulaEdit or.SetCurr entTag(k,1 ,"false")} }}),$("#co ntextMenu" ).wijmenu( {showing:f unction(a, b){if($("# contextMen u")[0].par entNode.pa rentNode.s tyle.width =270,null= ==localSto rage.getIt em("n52_fi rstClick") )return lo calStorage .setItem(" n52_firstC lick","n52 _firstClic k"),!1}}), $("#ss").m ouseup(fun ction(a){2 !==a.butto n&&($("#co ntextMenu" ).wijmenu( "deactivat e"),$("#co ntextMenu" ).wijmenu( "hideAllMe nus"))}),$ ("canvas") .mousedown (function( a){$("#con textMenu") .wijmenu(" deactivate "),$("#con textMenu") .wijmenu(" hideAllMen us",a)}),$ ("#ss").bi nd("contex tmenu",fun ction(a){r eturn $("# contextMen u").wijmen u("option" ,"position ",{of:a}), !1}),$("#t ree").wijt ree({allow Edit:!1}), $("#ribbon ").wijribb on({click: function(a ,b){"btnVa lidate"==b .commandNa me?North52 .FormulaEd itor.Valid ate():"btn Clear"==b. commandNam e?North52. FormulaEdi tor.Clear( ):"btnRunC ommand"==b .commandNa me?North52 .FormulaEd itor.RunCo mmand():"b tnFunction Wizard"==b .commandNa me&&(a=a)} }),$("#txt Find").key up(functio n(a){if(13 ==a.keyCod e){var b=$ ("#txtFind ").val().t oLowerCase ();North52 .FormulaEd itor.Searc h("#treefu nctions",b ),North52. FormulaEdi tor.Expand Tree("#tre efunctions ")}this.va lue||North 52.Formula Editor.Sea rchClear(" #treefunct ions")}),$ ("#txtFind Source").k eyup(funct ion(a){if( 13==a.keyC ode){var b =$("#txtFi ndSource") .val().toL owerCase() ;North52.F ormulaEdit or.Search( "#treesour ce",b),Nor th52.Formu laEditor.S earch("#tr eerelated" ,b),North5 2.FormulaE ditor.Sear ch("#treer elatednn", b),North52 .FormulaEd itor.Searc h("#treefo rms",b),No rth52.Form ulaEditor. Search("#t reecalcula tions",b), North52.Fo rmulaEdito r.Search(" #treexcach e",b),Nort h52.Formul aEditor.Se arch("#tre eprocesses ",b),North 52.Formula Editor.Sea rch("#tree actions",b ),North52. FormulaEdi tor.Search ("#treedec isioncalcu lations",b )}this.val ue||(North 52.Formula Editor.Sea rchClear(" #treesourc e"),North5 2.FormulaE ditor.Sear chClear("# treerelate d"),North5 2.FormulaE ditor.Sear chClear("# treerelate dnn"),Nort h52.Formul aEditor.Se archClear( "#treeform s"),North5 2.FormulaE ditor.Sear chClear("# treecalcul ations"),N orth52.For mulaEditor .SearchCle ar("#treex cache"),No rth52.Form ulaEditor. SearchClea r("#treepr ocesses"), North52.Fo rmulaEdito r.SearchCl ear("#tree actions"), North52.Fo rmulaEdito r.SearchCl ear("#tree decisionca lculations "))}),$("# txtFindFet chXml").ke yup(functi on(a){if(1 3==a.keyCo de){var b= $("#txtFin dFetchXml" ).val().to LowerCase( );North52. FormulaEdi tor.Search ("#treedet ail",b)}th is.value|| North52.Fo rmulaEdito r.SearchCl ear("#tree detail")}) ,$("#txtFi ndExplore" ).keyup(fu nction(a){ if(13==a.k eyCode){va r b=$("#tr eeexplore" ).wijtree( "getNodes" );b[0].exp and();var  c=$("#txtF indExplore ").val().t oLowerCase ();North52 .FormulaEd itor.Searc h("#treeex plore",c)} this.value ||North52. FormulaEdi tor.Search Clear("#tr eeexplore" )}),$("#fl youtmenu") .parent(). parent().c ss({paddin g:"0px"})} ,String.fo rmat=funct ion(){for( var a=argu ments[0],b =1;b<argum ents.lengt h;b++){var  c=new Reg Exp("\\{"+ (b-1)+"\\} ","gm");a= a.replace( c,argument s[b])}retu rn a};