350. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 5/9/2017 12:03:04 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.

350.1 Files compared

# Location File Last Modified
1 Tue May 9 16:03:04 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_Javascriptsdkmetadatajs4407A3BC-D29D-E011-A17A-00155DF5B00D Mon Sep 19 18:20:18 2016 UTC

350.2 Comparison summary

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

350.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

350.4 Active regular expressions

No regular expressions were active.

350.5 Comparison detail

        1   SDK = wind ow.SDK ||  { __namesp ace: true  };
        2   SDK.Metada ta = SDK.M etadata ||  { __names pace: true  };
        3  
        4   (function  () {
        5  
        6  
        7    this.Retr ieveAllEnt ities = fu nction (En tityFilter s, Retriev eAsIfPubli shed, succ essCallBac k, errorCa llBack, pa ssThroughO bject) {
        8     ///<summ ary>
        9     /// Send s an async hronous Re trieveAllE ntities Re quest to r etrieve al l entities  in the sy stem
        10     ///</sum mary>
        11     ///<retu rns>entity MetadataCo llection</ returns>
        12     ///<para m name="En tityFilter s" type="N umber">
        13     /// SDK. Metadata.E ntityFilte rs provide s an enume ration for  the filte rs availab le to filt er which d ata is ret rieved.
        14     /// Incl ude only t hose eleme nts of the  entity yo u want to  retrieve.  Retrieving  all parts  of all en titities m ay take si gnificant  time.
        15     ///</par am>
        16     ///<para m name="Re trieveAsIf Published"  type="Boo lean">
        17     /// Sets  whether t o retrieve  the metad ata that h as not bee n publishe d.
        18     ///</par am>
        19     ///<para m name="su ccessCallB ack" type= "Function" >
        20     /// The  function t hat will b e passed t hrough and  be called  by a succ essful res ponse.
        21     /// This  function  must accep t the enti tyMetadata Collection  as a para meter.
        22     ///</par am>
        23     ///<para m name="er rorCallBac k" type="F unction">
        24     /// The  function t hat will b e passed t hrough and  be called  by a fail ed respons e.
        25     /// This  function  must accep t an Error  object as  a paramet er.
        26     ///</par am>
        27     ///<para m name="pa ssThroughO bject" opt ional="tru e"  type=" Object">
        28     /// An O bject that  will be p assed thro ugh to as  the second  parameter  to the su ccessCallB ack.
        29     ///</par am>
        30     if ((typ eof Entity Filters !=  "number")  || (Entit yFilters <  1 || Enti tyFilters  > 15))
        31     { throw  new Error( "SDK.Metad ata.Retrie veAllEntit ies Entity Filters mu st be a SD K.Metadata .EntityFil ters value ."); }
        32     if (type of Retriev eAsIfPubli shed != "b oolean")
        33     { throw  new Error( "SDK.Metad ata.Retrie veAllEntit ies Retrie veAsIfPubl ished must  be a bool ean value. "); }
        34     if (type of success CallBack ! = "functio n")
        35     { throw  new Error( "SDK.Metad ata.Retrie veAllEntit ies succes sCallBack  must be a  function." ); }
        36     if (type of errorCa llBack !=  "function" )
        37     { throw  new Error( "SDK.Metad ata.Retrie veAllEntit ies errorC allBack mu st be a fu nction.");  }
        38  
        39     var enti tyFiltersV alue = _ev aluateEnti tyFilters( EntityFilt ers);
        40  
        41     var requ est = [
        42     "<soapen v:Envelope  xmlns:soa penv=\"htt p://schema s.xmlsoap. org/soap/e nvelope/\" >",
        43      "<soape nv:Body>",
        44       "<Exec ute xmlns= \"http://s chemas.mic rosoft.com /xrm/2011/ Contracts/ Services\"  xmlns:i=\ "http://ww w.w3.org/2 001/XMLSch ema-instan ce\">",
        45        "<req uest i:typ e=\"a:Retr ieveAllEnt itiesReque st\" xmlns :a=\"http: //schemas. microsoft. com/xrm/20 11/Contrac ts\">",
        46         "<a: Parameters  xmlns:b=\ "http://sc hemas.data contract.o rg/2004/07 /System.Co llections. Generic\"> ",
        47          "<a :KeyValueP airOfstrin ganyType>" ,
        48           "< b:key>Enti tyFilters< /b:key>",
        49           "< b:value i: type=\"c:E ntityFilte rs\" xmlns :c=\"http: //schemas. microsoft. com/xrm/20 11/Metadat a\">" + _x mlEncode(e ntityFilte rsValue) +  "</b:valu e>",
        50          "</ a:KeyValue PairOfstri nganyType> ",
        51          "<a :KeyValueP airOfstrin ganyType>" ,
        52           "< b:key>Retr ieveAsIfPu blished</b :key>",
        53           "< b:value i: type=\"c:b oolean\" x mlns:c=\"h ttp://www. w3.org/200 1/XMLSchem a\">" + _x mlEncode(R etrieveAsI fPublished .toString( )) + "</b: value>",
        54          "</ a:KeyValue PairOfstri nganyType> ",
        55         "</a :Parameter s>",
        56         "<a: RequestId  i:nil=\"tr ue\" />",
        57         "<a: RequestNam e>Retrieve AllEntitie s</a:Reque stName>",
        58       "</req uest>",
        59      "</Exec ute>",
        60     "</soape nv:Body>",
        61     "</soape nv:Envelop e>"].join( "");
        62     var req  = new XMLH ttpRequest ();
        63     req.open ("POST", _ getUrl() +  "/XRMServ ices/2011/ Organizati on.svc/web ", true);
        64     try { re q.response Type = 'ms xml-docume nt'} catch (e){}
        65     req.setR equestHead er("Accept ", "applic ation/xml,  text/xml,  */*");
        66     req.setR equestHead er("Conten t-Type", " text/xml;  charset=ut f-8");
        67     req.setR equestHead er("SOAPAc tion", "ht tp://schem as.microso ft.com/xrm /2011/Cont racts/Serv ices/IOrga nizationSe rvice/Exec ute");
        68     req.onre adystatech ange = fun ction () {
        69      if (req .readyStat e == 4 /*  complete * /) {
        70      req.onr eadystatec hange = nu ll; //Addr esses pote ntial memo ry leak is sue with I E
        71       if (re q.status = = 200) {
        72        //Suc cess                            
        73        var d oc = req.r esponseXML ;
        74        try{_ setSelecti onNamespac es(doc);}c atch(e){}
        75        var e ntityMetad ataNodes =  _selectNo des(doc, " //c:Entity Metadata") ;
        76        var e ntityMetad ataCollect ion = [];
        77        for ( var i = 0;  i < entit yMetadataN odes.lengt h; i++) {
        78         var  a = _objec tifyNode(e ntityMetad ataNodes[i ]);
        79         a._t ype = "Ent ityMetadat a";
        80         enti tyMetadata Collection .push(a);
        81        }
        82  
        83        succe ssCallBack (entityMet adataColle ction, pas sThroughOb ject);
        84       }
        85       else {
        86        error CallBack(_ getError(r eq));
        87       }
        88      }
        89     };
        90     req.send (request);
        91  
        92    };
        93  
        94    this.Retr ieveEntity  = functio n (EntityF ilters, Lo gicalName,  MetadataI d, Retriev eAsIfPubli shed, succ essCallBac k, errorCa llBack, pa ssThroughO bject) {
        95     ///<summ ary>
        96     /// Send s an async hronous Re trieveEnti ty Request  to retrie ve a speci fic entity
        97     ///</sum mary>
        98     ///<retu rns>entity Metadata</ returns>
        99     ///<para m name="En tityFilter s" type="N umber">
        100     /// SDK. Metadata.E ntityFilte rs provide s an enume ration for  the filte rs availab le to filt er which d ata is ret rieved.
        101     /// Incl ude only t hose eleme nts of the  entity yo u want to  retrieve.  Retrieving  all parts  of all en titities m ay take si gnificant  time.
        102     ///</par am>
        103     ///<para m name="Lo gicalName"  optional= "true" typ e="String" >
        104     /// The  logical na me of the  entity req uested. A  null value  may be us ed if a Me tadataId i s provided .
        105     ///</par am>
        106     ///<para m name="Me tadataId"  optional=" true" type ="String">
        107     /// A nu ll value o r an empty  guid may  be passed  if a Logic alName is  provided.
        108     ///</par am>
        109     ///<para m name="Re trieveAsIf Published"  type="Boo lean">
        110     /// Sets  whether t o retrieve  the metad ata that h as not bee n publishe d.
        111     ///</par am>
        112     ///<para m name="su ccessCallB ack" type= "Function" >
        113     /// The  function t hat will b e passed t hrough and  be called  by a succ essful res ponse.
        114     /// This  function  must accep t the enti tyMetadata  as a para meter.
        115     ///</par am>
        116     ///<para m name="er rorCallBac k" type="F unction">
        117     /// The  function t hat will b e passed t hrough and  be called  by a fail ed respons e.
        118     /// This  function  must accep t an Error  object as  a paramet er.
        119     ///</par am>
        120     ///<para m name="pa ssThroughO bject" opt ional="tru e"  type=" Object">
        121     /// An O bject that  will be p assed thro ugh to as  the second  parameter  to the su ccessCallB ack.
        122     ///</par am>
        123     if ((typ eof Entity Filters !=  "number")  || (Entit yFilters <  1 || Enti tyFilters  > 15))
        124     { throw  new Error( "SDK.Metad ata.Retrie veEntity E ntityFilte rs must be  a SDK.Met adata.Enti tyFilters  value.");  }
        125     if (Logi calName ==  null && M etadataId  == null) {
        126      throw n ew Error(" SDK.Metada ta.Retriev eEntity re quires eit her the Lo gicalName  or Metadat aId parame ter not be  null.");
        127     }
        128     if (Logi calName !=  null) {
        129      if (typ eof Logica lName != " string")
        130      { throw  new Error ("SDK.Meta data.Retri eveEntity  LogicalNam e must be  a string v alue."); }
        131      Metadat aId = "000 00000-0000 -0000-0000 -000000000 000";
        132     }
        133     if (Meta dataId !=  null && Lo gicalName  == null) {
        134      if (typ eof Metada taId != "s tring")
        135      { throw  new Error ("SDK.Meta data.Retri eveEntity  MetadataId  must be a  string va lue."); }
        136     }
        137     if (type of Retriev eAsIfPubli shed != "b oolean")
        138     { throw  new Error( "SDK.Metad ata.Retrie veEntity R etrieveAsI fPublished  must be a  boolean v alue."); }
        139     if (type of success CallBack ! = "functio n")
        140     { throw  new Error( "SDK.Metad ata.Retrie veEntity s uccessCall Back must  be a funct ion."); }
        141     if (type of errorCa llBack !=  "function" )
        142     { throw  new Error( "SDK.Metad ata.Retrie veEntity e rrorCallBa ck must be  a functio n."); }
        143     var enti tyFiltersV alue = _ev aluateEnti tyFilters( EntityFilt ers);
        144  
        145     var enti tyLogicalN ameValueNo de = "";
        146     if (Logi calName ==  null)
        147     { entity LogicalNam eValueNode  = "<b:val ue i:nil=\ "true\" /> "; }
        148     else
        149     { entity LogicalNam eValueNode  = "<b:val ue i:type= \"c:string \"   xmlns :c=\"http: //www.w3.o rg/2001/XM LSchema\"> " + _xmlEn code(Logic alName.toL owerCase() ) + "</b:v alue>"; }
        150     var requ est = [
        151     "<soapen v:Envelope  xmlns:soa penv=\"htt p://schema s.xmlsoap. org/soap/e nvelope/\" >",
        152      "<soape nv:Body>",
        153       "<Exec ute xmlns= \"http://s chemas.mic rosoft.com /xrm/2011/ Contracts/ Services\"  xmlns:i=\ "http://ww w.w3.org/2 001/XMLSch ema-instan ce\">",
        154        "<req uest i:typ e=\"a:Retr ieveEntity Request\"  xmlns:a=\" http://sch emas.micro soft.com/x rm/2011/Co ntracts\"> ",
        155         "<a: Parameters  xmlns:b=\ "http://sc hemas.data contract.o rg/2004/07 /System.Co llections. Generic\"> ",
        156          "<a :KeyValueP airOfstrin ganyType>" ,
        157           "< b:key>Enti tyFilters< /b:key>",
        158           "< b:value i: type=\"c:E ntityFilte rs\" xmlns :c=\"http: //schemas. microsoft. com/xrm/20 11/Metadat a\">" + _x mlEncode(e ntityFilte rsValue) +  "</b:valu e>",
        159          "</ a:KeyValue PairOfstri nganyType> ",
        160          "<a :KeyValueP airOfstrin ganyType>" ,
        161           "< b:key>Meta dataId</b: key>",
        162           "< b:value i: type=\"ser :guid\"  x mlns:ser=\ "http://sc hemas.micr osoft.com/ 2003/10/Se rializatio n/\">" + _ xmlEncode( MetadataId ) + "</b:v alue>",
        163          "</ a:KeyValue PairOfstri nganyType> ",
        164          "<a :KeyValueP airOfstrin ganyType>" ,
        165           "< b:key>Retr ieveAsIfPu blished</b :key>",
        166           "< b:value i: type=\"c:b oolean\" x mlns:c=\"h ttp://www. w3.org/200 1/XMLSchem a\">" + _x mlEncode(R etrieveAsI fPublished .toString( )) + "</b: value>",
        167          "</ a:KeyValue PairOfstri nganyType> ",
        168          "<a :KeyValueP airOfstrin ganyType>" ,
        169           "< b:key>Logi calName</b :key>",
        170            e ntityLogic alNameValu eNode,
        171          "</ a:KeyValue PairOfstri nganyType> ",
        172         "</a :Parameter s>",
        173         "<a: RequestId  i:nil=\"tr ue\" />",
        174         "<a: RequestNam e>Retrieve Entity</a: RequestNam e>",
        175        "</re quest>",
        176       "</Exe cute>",
        177      "</soap env:Body>" ,
        178     "</soape nv:Envelop e>"].join( "");
        179     var req  = new XMLH ttpRequest ();
        180     req.open ("POST", _ getUrl() +  "/XRMServ ices/2011/ Organizati on.svc/web ", true);
        181     try { re q.response Type = 'ms xml-docume nt'} catch (e){}
        182     req.setR equestHead er("Accept ", "applic ation/xml,  text/xml,  */*");
        183     req.setR equestHead er("Conten t-Type", " text/xml;  charset=ut f-8");
        184     req.setR equestHead er("SOAPAc tion", "ht tp://schem as.microso ft.com/xrm /2011/Cont racts/Serv ices/IOrga nizationSe rvice/Exec ute");
        185     req.onre adystatech ange = fun ction () {
        186      if (req .readyStat e == 4 /*  complete * /) {
        187      req.onr eadystatec hange = nu ll; //Addr esses pote ntial memo ry leak is sue with I E
        188       if (re q.status = = 200) {
        189        var d oc = req.r esponseXML ;
        190        try{_ setSelecti onNamespac es(doc);}c atch(e){}
        191        var a  = _object ifyNode(_s electSingl eNode(doc,  "//b:valu e"));
        192        a._ty pe = "Enti tyMetadata ";
        193        succe ssCallBack (a, passTh roughObjec t);
        194       }
        195       else {
        196        //Fai lure
        197        error CallBack(_ getError(r eq));
        198       }
        199      }
        200  
        201     };
        202     req.send (request);
        203  
        204  
        205    };
        206  
        207    this.Retr ieveAttrib ute = func tion (Enti tyLogicalN ame, Logic alName, Me tadataId,  RetrieveAs IfPublishe d, success CallBack,  errorCallB ack, passT hroughObje ct) {
        208     ///<summ ary>
        209     /// Send s an async hronous Re trieveAttr ibute Requ est to ret rieve a sp ecific ent ity
        210     ///</sum mary>
        211     ///<retu rns>Attrib uteMetadat a</returns >
        212     ///<para m name="En tityLogica lName"  op tional="tr ue" type=" String">
        213     /// The  logical na me of the  entity for  the attri bute reque sted. A nu ll value m ay be used  if a Meta dataId is  provided.
        214     ///</par am>
        215     ///<para m name="Lo gicalName"  optional= "true" typ e="String" >
        216     /// The  logical na me of the  attribute  requested.  
        217     ///</par am>
        218     ///<para m name="Me tadataId"  optional=" true" type ="String">
        219     /// A nu ll value m ay be pass ed if an E ntityLogic alName and  LogicalNa me is prov ided.
        220     ///</par am>
        221     ///<para m name="Re trieveAsIf Published"  type="Boo lean">
        222     /// Sets  whether t o retrieve  the metad ata that h as not bee n publishe d.
        223     ///</par am>
        224     ///<para m name="su ccessCallB ack" type= "Function" >
        225     /// The  function t hat will b e passed t hrough and  be called  by a succ essful res ponse.
        226     /// This  function  must accep t the enti tyMetadata  as a para meter.
        227     ///</par am>
        228     ///<para m name="er rorCallBac k" type="F unction">
        229     /// The  function t hat will b e passed t hrough and  be called  by a fail ed respons e.
        230     /// This  function  must accep t an Error  object as  a paramet er.
        231     ///</par am>
        232     ///<para m name="pa ssThroughO bject" opt ional="tru e"  type=" Object">
        233     /// An O bject that  will be p assed thro ugh to as  the second  parameter  to the su ccessCallB ack.
        234     ///</par am>
        235     if (Enti tyLogicalN ame == nul l && Logic alName ==  null && Me tadataId = = null) {
        236      throw n ew Error(" SDK.Metada ta.Retriev eAttribute  requires  either the  EntityLog icalName a nd Logical Name  para meters or  the Metada taId param eter not b e null.");
        237     }
        238     if (Meta dataId !=  null && En tityLogica lName == n ull && Log icalName = = null) {
        239      if (typ eof Metada taId != "s tring")
        240      { throw  new Error ("SDK.Meta data.Retri eveEntity  MetadataId  must be a  string va lue."); }
        241     }
        242     else
        243     { Metada taId = "00 000000-000 0-0000-000 0-00000000 0000"; }
        244     if (Enti tyLogicalN ame != nul l) {
        245      if (typ eof Entity LogicalNam e != "stri ng") {
        246       { thro w new Erro r("SDK.Met adata.Retr ieveAttrib ute Entity LogicalNam e must be  a string v alue."); }
        247      }
        248     }
        249     if (Logi calName !=  null) {
        250      if (typ eof Logica lName != " string") {
        251       { thro w new Erro r("SDK.Met adata.Retr ieveAttrib ute Logica lName must  be a stri ng value." ); }
        252      }
        253  
        254     }
        255     if (type of Retriev eAsIfPubli shed != "b oolean")
        256     { throw  new Error( "SDK.Metad ata.Retrie veAttribut e Retrieve AsIfPublis hed must b e a boolea n value.") ; }
        257     if (type of success CallBack ! = "functio n")
        258     { throw  new Error( "SDK.Metad ata.Retrie veAttribut e successC allBack mu st be a fu nction.");  }
        259     if (type of errorCa llBack !=  "function" )
        260     { throw  new Error( "SDK.Metad ata.Retrie veAttribut e errorCal lBack must  be a func tion."); }
        261  
        262     var enti tyLogicalN ameValueNo de;
        263     if (Enti tyLogicalN ame == nul l) {
        264      entityL ogicalName ValueNode  = "<b:valu e i:nil=\" true\" />" ;
        265     }
        266     else {
        267      entityL ogicalName ValueNode  = "<b:valu e i:type=\ "c:string\ " xmlns:c= \"http://w ww.w3.org/ 2001/XMLSc hema\">" +  _xmlEncod e(EntityLo gicalName. toLowerCas e()) + "</ b:value>";
        268     }
        269     var logi calNameVal ueNode;
        270     if (Logi calName ==  null) {
        271      logical NameValueN ode = "<b: value i:ni l=\"true\"  />";
        272     }
        273     else {
        274      logical NameValueN ode = "<b: value i:ty pe=\"c:str ing\"   xm lns:c=\"ht tp://www.w 3.org/2001 /XMLSchema \">" + _xm lEncode(Lo gicalName. toLowerCas e()) + "</ b:value>";
        275     }
        276     var requ est = [
        277     "<soapen v:Envelope  xmlns:soa penv=\"htt p://schema s.xmlsoap. org/soap/e nvelope/\" >",
        278      "<soape nv:Body>",
        279       "<Exec ute xmlns= \"http://s chemas.mic rosoft.com /xrm/2011/ Contracts/ Services\"  xmlns:i=\ "http://ww w.w3.org/2 001/XMLSch ema-instan ce\">",
        280        "<req uest i:typ e=\"a:Retr ieveAttrib uteRequest \" xmlns:a =\"http:// schemas.mi crosoft.co m/xrm/2011 /Contracts \">",
        281         "<a: Parameters  xmlns:b=\ "http://sc hemas.data contract.o rg/2004/07 /System.Co llections. Generic\"> ",
        282          "<a :KeyValueP airOfstrin ganyType>" ,
        283           "< b:key>Enti tyLogicalN ame</b:key >",
        284            e ntityLogic alNameValu eNode,
        285          "</ a:KeyValue PairOfstri nganyType> ",
        286          "<a :KeyValueP airOfstrin ganyType>" ,
        287           "< b:key>Meta dataId</b: key>",
        288           "< b:value i: type=\"ser :guid\"  x mlns:ser=\ "http://sc hemas.micr osoft.com/ 2003/10/Se rializatio n/\">" + _ xmlEncode( MetadataId ) + "</b:v alue>",
        289          "</ a:KeyValue PairOfstri nganyType> ",
        290           "< a:KeyValue PairOfstri nganyType> ",
        291           "< b:key>Retr ieveAsIfPu blished</b :key>",
        292         "<b: value i:ty pe=\"c:boo lean\" xml ns:c=\"htt p://www.w3 .org/2001/ XMLSchema\ ">" + _xml Encode(Ret rieveAsIfP ublished.t oString())  + "</b:va lue>",
        293          "</ a:KeyValue PairOfstri nganyType> ",
        294          "<a :KeyValueP airOfstrin ganyType>" ,
        295           "< b:key>Logi calName</b :key>",
        296            l ogicalName ValueNode,
        297          "</ a:KeyValue PairOfstri nganyType> ",
        298         "</a :Parameter s>",
        299         "<a: RequestId  i:nil=\"tr ue\" />",
        300         "<a: RequestNam e>Retrieve Attribute< /a:Request Name>",
        301        "</re quest>",
        302       "</Exe cute>",
        303      "</soap env:Body>" ,
        304     "</soape nv:Envelop e>"].join( "");
        305     var req  = new XMLH ttpRequest ();
        306     req.open ("POST", _ getUrl() +  "/XRMServ ices/2011/ Organizati on.svc/web ", true);
        307     req.setR equestHead er("Accept ", "applic ation/xml,  text/xml,  */*");
        308     req.setR equestHead er("Conten t-Type", " text/xml;  charset=ut f-8");
        309     req.setR equestHead er("SOAPAc tion", "ht tp://schem as.microso ft.com/xrm /2011/Cont racts/Serv ices/IOrga nizationSe rvice/Exec ute");
        310     req.onre adystatech ange = fun ction () {
        311      if (req .readyStat e == 4 /*  complete * /) {
        312      req.onr eadystatec hange = nu ll; //Addr esses pote ntial memo ry leak is sue with I E
        313       if (re q.status = = 200) {
        314        //Suc cess
        315        var d oc = req.r esponseXML ;
        316        try{_ setSelecti onNamespac es(doc);}c atch(e){}
        317        var a  = _object ifyNode(_s electSingl eNode(doc,  "//b:valu e"));
        318                                      
        319        succe ssCallBack (a, passTh roughObjec t);
        320       }
        321       else {
        322        //Fai lure
        323        error CallBack(_ getError(r eq));
        324       }
        325      }
        326     };
        327     req.send (request);
        328  
        329  
        330    };
        331  
        332    this.Enti tyFilters  = function  () {
        333     /// <sum mary>SDK.M etadata.En tityFilter s enum sum mary</summ ary>
        334     /// <fie ld name="D efault" ty pe="Number " static=" true">enum  field sum mary for D efault</fi eld>
        335     /// <fie ld name="E ntity" typ e="Number"  static="t rue">enum  field summ ary for En tity</fiel d>
        336     /// <fie ld name="A ttributes"  type="Num ber" stati c="true">e num field  summary fo r Attribut es</field>
        337     /// <fie ld name="P rivileges"  type="Num ber" stati c="true">e num field  summary fo r Privileg es</field>
        338     /// <fie ld name="R elationshi ps" type=" Number" st atic="true ">enum fie ld summary  for Relat ionships</ field>
        339     /// <fie ld name="A ll" type=" Number" st atic="true ">enum fie ld summary  for All</ field>
        340     throw ne w Error("C onstructor  not imple mented thi s is a sta tic enum." );
        341    };
        342  
        343  
        344  
        345    var _arra yElements  = ["Attrib utes",
        346     "ManyToM anyRelatio nships",
        347     "ManyToO neRelation ships",
        348     "OneToMa nyRelation ships",
        349     "Privile ges",
        350     "Localiz edLabels",
        351     "Options ",
        352     "Targets "];
        353  
        354     function  _getError (resp) {
        355     ///<summ ary>
        356     /// Priv ate functi on that at tempts to  parse erro rs related  to connec tivity or  WCF faults .
        357     ///</sum mary>
        358     ///<para m name="re sp" type=" XMLHttpReq uest">
        359     /// The  XMLHttpReq uest repre senting fa iled respo nse.
        360     ///</par am>
        361  
        362     //Error  descriptio ns come fr om http:// support.mi crosoft.co m/kb/19362 5
        363     if (resp .status ==  12029)
        364     { return  new Error ("The atte mpt to con nect to th e server f ailed.");  }
        365     if (resp .status ==  12007)
        366     { return  new Error ("The serv er name co uld not be  resolved. "); }
        367     var faul tXml = res p.response XML;
        368     var erro rMessage =  "Unknown  (unable to  parse the  fault)";
        369     if (type of faultXm l == "obje ct") {
        370  
        371      var fau ltstring =  null;
        372      var Err orCode = n ull;
        373  
        374      var bod yNode = fa ultXml.fir stChild.fi rstChild;
        375  
        376      //Retri eve the fa ult node
        377      for (va r i = 0; i  < bodyNod e.childNod es.length;  i++) {
        378       var no de = bodyN ode.childN odes[i];
        379  
        380       //NOTE : This com parison do es not han dle the ca se where t he XML nam espace cha nges
        381       if ("s :Fault" ==  node.node Name) {
        382        for ( var j = 0;  j < node. childNodes .length; j ++) {
        383         var  testNode =  node.chil dNodes[j];
        384         if ( "faultstri ng" == tes tNode.node Name) {
        385          fau ltstring =  _getNodeT ext(testNo de);
        386         }
        387         if ( "detail" = = testNode .nodeName)  {
        388          for  (var k =  0; k < tes tNode.chil dNodes.len gth; k++)  {
        389           va r orgServi ceFault =  testNode.c hildNodes[ k];
        390           if  ("Organiz ationServi ceFault" = = orgServi ceFault.no deName) {
        391            f or (var l  = 0; l < o rgServiceF ault.child Nodes.leng th; l++) {
        392              var ErrorC odeNode =  orgService Fault.chil dNodes[l];
        393              if ("Error Code" == E rrorCodeNo de.nodeNam e) {
        394               ErrorCode  = _getNod eText(Erro rCodeNode) ;
        395               break;
        396              }
        397            }
        398           }
        399          }
        400  
        401         }
        402        }
        403        break ;
        404       }
        405  
        406      }
        407     }
        408     if (Erro rCode != n ull && fau ltstring ! = null) {
        409      errorMe ssage = "E rror Code: " + ErrorC ode + " Me ssage: " +  faultstri ng;
        410     }
        411     else {
        412      if (fau ltstring ! = null) {
        413       errorM essage = f aultstring ;
        414      }
        415     }
        416     return n ew Error(e rrorMessag e);
        417    };
        418  
        419    function  _Context()  {
        420     var erro rMessage =  "Context  is not ava ilable.";
        421     if (type of GetGlob alContext  != "undefi ned")
        422     { return  GetGlobal Context();  }
        423     else {
        424      if (typ eof Xrm !=  "undefine d") {
        425       return  Xrm.Page. context;
        426      }
        427      else
        428      { retur n new Erro r(errorMes sage); }
        429     }
        430    };
        431  
        432    function  _getUrl()  {
        433      var url  = "unknow n";
        434  
        435      if (typ eof _Conte xt().getSe rverUrl !=  "undefine d") {
        436            u rl = _Cont ext().getS erverUrl() ;
        437            u rl = url . replace(/^ (http|http s):\/\/([_ a-zA-Z0-9\ -\.]+)(:([ 0-9]{1,5}) )?/, windo w.location .protocol  + "//" + w indow.loca tion.host) ;
        438            u rl = url . replace(/\ /$/, "");
        439       }
        440  
        441     if (type of _Contex t().getCli entUrl !=  "undefined ") {
        442      url = _ Context(). getClientU rl();
        443     }
        444     return u rl;
        445    };
        446  
        447    function  _evaluateE ntityFilte rs(EntityF ilters) {
        448     var enti tyFilterAr ray = [];
        449     if ((1 &  EntityFil ters) == 1 ) {
        450      entityF ilterArray .push("Ent ity");
        451     }
        452     if ((2 &  EntityFil ters) == 2 ) {
        453      entityF ilterArray .push("Att ributes");
        454     }
        455     if ((4 &  EntityFil ters) == 4 ) {
        456      entityF ilterArray .push("Pri vileges");
        457     }
        458     if ((8 &  EntityFil ters) == 8 ) {
        459      entityF ilterArray .push("Rel ationships ");
        460     }
        461     return e ntityFilte rArray.joi n(" ");
        462    };
        463  
        464    function  _isMetadat aArray(ele mentName)  {
        465     for (var  i = 0; i  < _arrayEl ements.len gth; i++)  {
        466      if (ele mentName = = _arrayEl ements[i])  {
        467       return  true;
        468      }
        469     }
        470     return f alse;
        471    };
        472  
        473    function  _objectify Node(node)  {
        474     //Check  for null
        475     if (node .attribute s != null  && node.at tributes.l ength == 1 ) {
        476      if (nod e.attribut es.getName dItem("i:n il") != nu ll && node .attribute s.getNamed Item("i:ni l").nodeVa lue == "tr ue") {
        477       return  null;
        478      }
        479     }
        480  
        481     //Check  if it is a  value
        482     if ((nod e.firstChi ld != null ) && (node .firstChil d.nodeType  == 3)) {
        483      var nod eName = _g etNodeName (node);
        484  
        485      switch  (nodeName)  {
        486       //Inte ger Values  
        487       case " ActivityTy peMask":
        488       case " ObjectType Code":
        489       case " ColumnNumb er":
        490       case " DefaultFor mValue":
        491       case " MaxValue":
        492       case " MinValue":
        493       case " MaxLength" :
        494       case " Order":
        495       case " Precision" :
        496       case " PrecisionS ource":
        497       case " LanguageCo de":
        498        retur n parseInt (node.firs tChild.nod eValue, 10 );
        499        // Bo olean valu es
        500       case " AutoRouteT oOwnerQueu e":
        501       case " CanBeChang ed":
        502       case " CanTrigger Workflow":
        503       case " IsActivity ":
        504       case " IsActivity Party":
        505       case " IsAvailabl eOffline":
        506       case " IsChildEnt ity":
        507       case " IsCustomEn tity":
        508       case " IsCustomOp tionSet":    
        509       case " IsDocument Management Enabled":
        510       case " IsEnabledF orCharts":
        511       case " IsGlobal":
        512       case " IsImportab le":
        513       case " IsIntersec t":
        514       case " IsManaged" :
        515       case " IsReadingP aneEnabled ":
        516       case " IsValidFor AdvancedFi nd":
        517       case " CanBeSecur edForCreat e":
        518       case " CanBeSecur edForRead" :
        519       case " CanBeSecur edForUpdat e":
        520       case " IsCustomAt tribute":
        521       case " IsManaged" :
        522       case " IsPrimaryI d":
        523       case " IsPrimaryN ame":
        524       case " IsSecured" :
        525       case " IsValidFor Create":
        526       case " IsValidFor Read":
        527       case " IsValidFor Update":
        528       case " IsCustomRe lationship ":
        529       case " CanBeBasic ":
        530       case " CanBeDeep" :
        531       case " CanBeGloba l":
        532       case " CanBeLocal ":
        533        retur n (node.fi rstChild.n odeValue = = "true")  ? true : f alse;
        534        //Opt ionMetadat a.Value an d BooleanM anagedProp erty.Value  and Attri buteRequir edLevelMan agedProper ty.Value
        535       case " Value":
        536        //Boo leanManage dProperty. Value
        537        if (( node.first Child.node Value == " true") ||  (node.firs tChild.nod eValue ==  "false"))  {
        538         retu rn (node.f irstChild. nodeValue  == "true")  ? true :  false;
        539        }
        540        //Att ributeRequ iredLevelM anagedProp erty.Value
        541        if (
        542     (node.fi rstChild.n odeValue = = "Applica tionRequir ed") ||
        543     (node.fi rstChild.n odeValue = = "None")  ||
        544     (node.fi rstChild.n odeValue = = "Recomme nded") ||
        545     (node.fi rstChild.n odeValue = = "SystemR equired")
        546     ) {
        547         retu rn node.fi rstChild.n odeValue;
        548        }
        549        else  {
        550         //Op tionMetada ta.Value
        551         retu rn parseIn t(node.fir stChild.no deValue, 1 0);
        552        }
        553        break ;
        554       //Stri ng values 
        555       defaul t:
        556        retur n node.fir stChild.no deValue;
        557      }
        558  
        559     }
        560  
        561     //Check  if it is a  known arr ay
        562     if (_isM etadataArr ay(_getNod eName(node ))) {
        563      var arr ayValue =  [];
        564  
        565      for (va r i = 0; i  < node.ch ildNodes.l ength; i++ ) {
        566       var ob jectTypeNa me;
        567       if ((n ode.childN odes[i].at tributes ! = null) &&  (node.chi ldNodes[i] .attribute s.getNamed Item("i:ty pe") != nu ll)) {
        568        objec tTypeName  = node.chi ldNodes[i] .attribute s.getNamed Item("i:ty pe").nodeV alue.split (":")[1];
        569       }
        570       else {
        571  
        572        objec tTypeName  = _getNode Name(node. childNodes [i]);
        573       }
        574  
        575       var b  = _objecti fyNode(nod e.childNod es[i]);
        576       b._typ e = object TypeName;
        577       arrayV alue.push( b);
        578  
        579      }
        580  
        581      return  arrayValue ;
        582     }
        583  
        584       //Null  entity de scription  labels are  returned  as <label/ > - not us ing i:nil  = true;
        585     if(node. childNodes .length ==  0)
        586     {
        587     return n ull;
        588     }
        589  
        590     //Otherw ise return  an object
        591     var c =  {};
        592     if (node .attribute s.getNamed Item("i:ty pe") != nu ll) {
        593      c._type  = node.at tributes.g etNamedIte m("i:type" ).nodeValu e.split(": ")[1];
        594     }
        595     for (var  i = 0; i  < node.chi ldNodes.le ngth; i++)  {
        596      if (nod e.childNod es[i].node Type == 3)  {
        597       c[_get NodeName(n ode.childN odes[i])]  = node.chi ldNodes[i] .nodeValue ;
        598      }
        599      else {
        600       c[_get NodeName(n ode.childN odes[i])]  = _objecti fyNode(nod e.childNod es[i]);
        601      }
        602  
        603     }
        604     return c ;
        605    };
        606  
        607    function  _selectNod es(node, X PathExpres sion) {
        608     if (type of (node.s electNodes ) != "unde fined") {
        609      return  node.selec tNodes(XPa thExpressi on);
        610     }
        611     else {
        612      var out put = [];
        613      var XPa thResults  = node.eva luate(XPat hExpressio n, node, _ NSResolver , XPathRes ult.ANY_TY PE, null);
        614      var res ult = XPat hResults.i terateNext ();
        615      while ( result) {
        616       output .push(resu lt);
        617       result  = XPathRe sults.iter ateNext();
        618      }
        619      return  output;
        620     }
        621    };
        622  
        623    function  _selectSin gleNode(no de, xpathE xpr) {
        624     if (type of (node.s electSingl eNode) !=  "undefined ") {
        625      return  node.selec tSingleNod e(xpathExp r);
        626     }
        627     else {
        628      var xpe  = new XPa thEvaluato r();
        629      var xPa thNode = x pe.evaluat e(xpathExp r, node, _ NSResolver , XPathRes ult.FIRST_ ORDERED_NO DE_TYPE, n ull);
        630      return  (xPathNode  != null)  ? xPathNod e.singleNo deValue :  null;
        631     }
        632    };
        633  
        634    function  _selectSin gleNodeTex t(node, xp athExpr) {
        635     var x =  _selectSin gleNode(no de, xpathE xpr);
        636     if (_isN odeNull(x) )
        637     { return  null; }
        638     if (type of (x.text ) != "unde fined") {
        639      return  x.text;
        640     }
        641     else {
        642      return  x.textCont ent;
        643     }
        644    };
        645  
        646    function  _getNodeTe xt(node) {
        647     if (type of (node.t ext) != "u ndefined")  {
        648      return  node.text;
        649     }
        650     else {
        651      return  node.textC ontent;
        652     }
        653    };
        654  
        655    function  _isNodeNul l(node) {
        656     if (node  == null)
        657     { return  true; }
        658     if ((nod e.attribut es.getName dItem("i:n il") != nu ll) && (no de.attribu tes.getNam edItem("i: nil").valu e == "true "))
        659     { return  true; }
        660     return f alse;
        661    };
        662  
        663    function  _getNodeNa me(node) {
        664     if (type of (node.b aseName) ! = "undefin ed") {
        665      return  node.baseN ame;
        666     }
        667     else {
        668      return  node.local Name;
        669     }
        670    };
        671  
        672    function  _setSelect ionNamespa ces(doc)
        673    {
        674    var names paces = [
        675    "xmlns:s= 'http://sc hemas.xmls oap.org/so ap/envelop e/'",
        676    "xmlns:a= 'http://sc hemas.micr osoft.com/ xrm/2011/C ontracts'" ,
        677    "xmlns:i= 'http://ww w.w3.org/2 001/XMLSch ema-instan ce'",
        678    "xmlns:b= 'http://sc hemas.data contract.o rg/2004/07 /System.Co llections. Generic'",
        679    "xmlns:c= 'http://sc hemas.micr osoft.com/ xrm/2011/M etadata'" 
        680    ];
        681    doc.setPr operty("Se lectionNam espaces",n amespaces. join(" ")) ;
        682    
        683    }
        684  
        685    function  _NSResolve r(prefix)  {
        686     var ns =  {
        687      "s": "h ttp://sche mas.xmlsoa p.org/soap /envelope/ ",
        688      "a": "h ttp://sche mas.micros oft.com/xr m/2011/Con tracts",
        689      "i": "h ttp://www. w3.org/200 1/XMLSchem a-instance ",
        690      "b": "h ttp://sche mas.dataco ntract.org /2004/07/S ystem.Coll ections.Ge neric",
        691      "c": "h ttp://sche mas.micros oft.com/xr m/2011/Met adata"
        692     };
        693     return n s[prefix]  || null;
        694    };
        695  
        696    function  _xmlEncode (strInput)  {
        697     var c;
        698     var XmlE ncode = '' ;
        699     if (strI nput == nu ll) {
        700      return  null;
        701     }
        702     if (strI nput == '' ) {
        703      return  '';
        704     }
        705     for (var  cnt = 0;  cnt < strI nput.lengt h; cnt++)  {
        706      c = str Input.char CodeAt(cnt );
        707      if (((c  > 96) &&  (c < 123))  ||
        708                             ((c >  64) && (c  < 91)) ||
        709                             (c ==  32) ||
        710                             ((c >  47) && (c  < 58)) ||
        711                             (c ==  46) ||
        712                             (c ==  44) ||
        713                             (c ==  45) ||
        714                             (c ==  95)) {
        715       XmlEnc ode = XmlE ncode + St ring.fromC harCode(c) ;
        716      }
        717      else {
        718       XmlEnc ode = XmlE ncode + '& #' + c + ' ;';
        719      }
        720     }
        721     return X mlEncode;
        722    };
        723  
        724   }).call(SD K.Metadata );
        725  
        726   //SDK.Meta data.Entit yFilters
        727   // this en um is writ ten this w ay to enab le Visual  Studio Int elliSense
        728   SDK.Metada ta.EntityF ilters.pro totype = {
        729    Default:  1,
        730    Entity: 1 ,
        731    Attribute s: 2,
        732    Privilege s: 4,
        733    Relations hips: 8,
        734    All: 15
        735   };
        736   SDK.Metada ta.EntityF ilters.Def ault = 1;
        737   SDK.Metada ta.EntityF ilters.Ent ity = 1;
        738   SDK.Metada ta.EntityF ilters.Att ributes =  2;
        739   SDK.Metada ta.EntityF ilters.Pri vileges =  4;
        740   SDK.Metada ta.EntityF ilters.Rel ationships  = 8;
        741   SDK.Metada ta.EntityF ilters.All  = 15;
        742   SDK.Metada ta.EntityF ilters.__e num = true ;
        743   SDK.Metada ta.EntityF ilters.__f lags = tru e;
        744  
        745  
        746   //</snippe tSDK.Metad ata.js>