@@ -8,7 +8,7 @@ OFM.Application.Form = OFM.Application.Form || {};
8
8
//Formload logic starts here
9
9
OFM . Application . Form = {
10
10
onLoad : function ( executionContext ) {
11
- // debugger;
11
+ debugger ;
12
12
let formContext = executionContext . getFormContext ( ) ;
13
13
switch ( formContext . ui . getFormType ( ) ) {
14
14
case 0 : //undefined
@@ -21,6 +21,7 @@ OFM.Application.Form = {
21
21
this . showBanner ( executionContext ) ;
22
22
this . filterCreatedBySPLookup ( executionContext ) ;
23
23
this . filterSubmittedByLookup ( executionContext ) ;
24
+ this . showCCFRIParticipation ( executionContext ) ;
24
25
break ;
25
26
26
27
case 2 : // update
@@ -36,6 +37,8 @@ OFM.Application.Form = {
36
37
this . showUnionList ( executionContext ) ;
37
38
this . showOtherDescription ( executionContext ) ;
38
39
this . notForProfitSection ( executionContext ) ;
40
+ this . showCCFRIParticipation ( executionContext ) ;
41
+ this . hideEligibilityTab ( executionContext ) ;
39
42
break ;
40
43
41
44
case 3 : //readonly
@@ -45,6 +48,8 @@ OFM.Application.Form = {
45
48
this . showUnionList ( executionContext ) ;
46
49
this . showOtherDescription ( executionContext ) ;
47
50
this . notForProfitSection ( executionContext ) ;
51
+ this . showCCFRIParticipation ( executionContext ) ;
52
+ this . hideEligibilityTab ( executionContext ) ;
48
53
break ;
49
54
50
55
case 4 : //disable
@@ -501,7 +506,7 @@ OFM.Application.Form = {
501
506
lockStatusReason : function ( executionContext ) {
502
507
debugger ;
503
508
var formContext = executionContext . getFormContext ( ) ;
504
- if ( formContext . getAttribute ( "statuscode" ) . getValue ( ) == 6 ) { //Approved
509
+ if ( formContext . getAttribute ( "statuscode" ) . getValue ( ) == 6 ) { //Approved
505
510
var roles = Xrm . Utility . getGlobalContext ( ) . userSettings . roles . getAll ( ) ;
506
511
var disable = true ;
507
512
for ( var i = 0 ; i < roles . length ; i ++ ) {
@@ -584,5 +589,41 @@ OFM.Application.Form = {
584
589
console . log ( error . message ) ;
585
590
}
586
591
) ;
592
+ } ,
593
+ showCCFRIParticipation : function ( executionContext ) {
594
+ debugger ;
595
+ var formContext = executionContext . getFormContext ( ) ;
596
+ var facility = formContext . getAttribute ( "ofm_facility" ) . getValue ( ) ;
597
+ var facilityid ;
598
+ if ( facility != null ) {
599
+ facilityid = facility [ 0 ] . id ;
600
+ Xrm . WebApi . retrieveRecord ( "account" , facilityid , "?$select=ofm_program" ) . then (
601
+ function success ( results ) {
602
+ console . log ( results ) ;
603
+ if ( results [ "ofm_program" ] === 2 || results [ "ofm_program" ] === 4 ) {
604
+ formContext . getControl ( "ofm_ccfri_participation" ) . setVisible ( true ) ;
605
+
606
+ }
607
+ else {
608
+ formContext . getControl ( "ofm_ccfri_participation" ) . setVisible ( false ) ;
609
+ }
610
+ } ,
611
+ function ( error ) {
612
+ console . log ( error . message ) ;
613
+ }
614
+ ) ;
615
+ }
616
+ } ,
617
+
618
+ hideEligibilityTab : function ( executionContext ) {
619
+ debugger ;
620
+ var formContext = executionContext . getFormContext ( ) ;
621
+ var applicationType = formContext . getAttribute ( "ofm_application_type" ) . getValue ( ) ;
622
+ if ( applicationType == 1 ) { //NEW
623
+ formContext . ui . tabs . get ( "tab_11" ) . setVisible ( true ) ;
624
+ }
625
+ else {
626
+ formContext . ui . tabs . get ( "tab_11" ) . setVisible ( false ) ;
627
+ }
587
628
}
588
629
}
0 commit comments