1
+ function hideFacilitiesSection ( executionContext ) {
2
+ var formContext = executionContext . getFormContext ( ) ;
3
+ var changeType = Xrm . Page . getAttribute ( "ccof_changetype" ) ;
4
+
5
+ if ( typeof ( changeType ) != "undefined" && changeType . getValue ( ) != null ) {
6
+
7
+ if ( changeType . getValue ( ) == 100000005 ) { //Value of "Add New Facility"
8
+ //hide the document list and mtfi
9
+ formContext . ui . tabs . get ( "general_tab" ) . sections . get ( "attachments_section" ) . setVisible ( false ) ;
10
+ formContext . ui . tabs . get ( "general_tab" ) . sections . get ( "mtfi_facilities_section" ) . setVisible ( false ) ;
11
+
12
+ //show the unlock section
13
+ formContext . ui . tabs . get ( "general_tab" ) . sections . get ( "org_unlock_section" ) . setVisible ( true ) ;
14
+ //hide the change request unlock and document unlock field
15
+ formContext . getControl ( "ccof_unlock_change_request" ) . setVisible ( false ) ;
16
+ formContext . getControl ( "ccof_unlock_other_changes_document" ) . setVisible ( false ) ;
17
+
18
+ } else if ( changeType . getValue ( ) == 100000007 ) { //Value of "MTFI"
19
+ //hide the document list and new facilities
20
+ //formContext.ui.tabs.get("general_tab").sections.get("attachments_section").setVisible(false);
21
+ formContext . ui . tabs . get ( "general_tab" ) . sections . get ( "new_facilities_section" ) . setVisible ( false ) ;
22
+ }
23
+ else if ( changeType . getValue ( ) == 100000015 || changeType . getValue ( ) == 100000016 || changeType . getValue ( ) == 100000017 ) { //Value of "NEW CLOSURE" "EDIT CLOSURE" "REMOVE CLOSURE"
24
+ debugger ;
25
+ formContext . ui . tabs . get ( "general_tab" ) . sections . get ( "change_action_closure_section" ) . setVisible ( true ) ;
26
+ formContext . ui . tabs . get ( "general_tab" ) . sections . get ( "new_facilities_section" ) . setVisible ( false ) ;
27
+ formContext . ui . tabs . get ( "general_tab" ) . sections . get ( "mtfi_facilities_section" ) . setVisible ( false ) ;
28
+
29
+ }
30
+ else { //Change type is other changes
31
+ //hide the mtfi and new facilities
32
+ formContext . ui . tabs . get ( "general_tab" ) . sections . get ( "new_facilities_section" ) . setVisible ( false ) ;
33
+ formContext . ui . tabs . get ( "general_tab" ) . sections . get ( "mtfi_facilities_section" ) . setVisible ( false ) ;
34
+
35
+ //show the unlock section
36
+ formContext . ui . tabs . get ( "general_tab" ) . sections . get ( "org_unlock_section" ) . setVisible ( true ) ;
37
+ //hide the ecewe unlock, licence upload unlock and supporting document unlock field
38
+ formContext . getControl ( "ccof_unlock_ccof" ) . setVisible ( false ) ;
39
+ formContext . getControl ( "ccof_unlock_ecewe" ) . setVisible ( false ) ;
40
+ formContext . getControl ( "ccof_unlock_licence_upload" ) . setVisible ( false ) ;
41
+ formContext . getControl ( "ccof_unlock_supporting_document" ) . setVisible ( false ) ;
42
+ }
43
+ }
44
+ }
45
+
46
+ //Open Unlock Notes Custom Page On save
47
+ function openCRUnlockCustomPage ( entityName , recordId ) {
48
+ var window_width = 1400 ;
49
+ var window_height = 900 ;
50
+
51
+ Xrm . WebApi . retrieveRecord ( entityName , recordId ) . then (
52
+ function success ( result ) {
53
+
54
+ //if Change Action type is not MTFI and New Facility
55
+ if ( result . ccof_changetype != 100000005 && result . ccof_changetype != 100000007 ) {
56
+ window_height = 417 ;
57
+ }
58
+ // console.log(result);
59
+ Xrm . Navigation . navigateTo ( {
60
+ pageType : "custom" ,
61
+ name : "ccof_changerequestunlockform_f6704" ,
62
+ entityName : entityName ,
63
+ recordId : recordId ,
64
+
65
+ } , {
66
+ target : 2 ,
67
+ width : window_width ,
68
+ height : window_height
69
+ } )
70
+ . then ( function ( ) {
71
+ // formContext.data.refresh();
72
+ } )
73
+ . catch ( console . error ) ;
74
+
75
+ } ,
76
+ function ( error ) {
77
+ console . log ( error . message ) ;
78
+ // handle error conditions
79
+ }
80
+ )
81
+
82
+ }
83
+ function showHideCreateUnlockButton ( primaryControl ) {
84
+ debugger ;
85
+ var formContext = primaryControl ;
86
+
87
+
88
+ var visible = false ;
89
+ var userRoles = Xrm . Utility . getGlobalContext ( ) . userSettings . roles ;
90
+ userRoles . forEach ( function hasRole ( item , index ) {
91
+ if ( item . name === "CCOF - Sr. Adjudicator" || item . name === "CCOF - Admin" || item . name === "CCOF - Leadership" || item . name === "System Administrator" ) {
92
+ visible = true ;
93
+ }
94
+ } ) ;
95
+ return visible ;
96
+ } ;
0 commit comments