forked from NYHTC/fm-functions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSessionOrgNum.xml
55 lines (44 loc) · 1.6 KB
/
SessionOrgNum.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<fmxmlsnippet type="FMObjectList">
<CustomFunction id="8" functionArity="1" visible="True" parameters="options" name="SessionOrgNum">
<Calculation><![CDATA[// SessionOrgNum ( options )
// version 1.4.1, NYHTC
/*
Returns this session's OrgNum.
Do this by trying to get the OrgNum from the privSet suffix, then accountName suffix, then defaulting to orgNum 1.
HISTORY:
1.4.1 - 2018-01-22 ( eshagdar ): explictly coerce to number, then do the comparison
1.4 - 2017-10-31 ( eshagdar ): get the orgNum based on the suffix of the PrivSet/AccountName
1.3.1 - 2017-06-02 ( dshockley/eshagdar ): Uses new method of querying an Organization Prefs table, instead of a client-side global.
1.2.1 - 2016-09-29 ( eshagdar ): updated documentation.
1.2 - 2016-07-06 ( eshagdar ): renamed '_SessionOrgNum' to 'SessionOrgNum'.
1.1 - 2016-xx-xx ( xxxxx ): updated to reference a00_TimesSquare's OrgNum instead of the local file's global OrgNum
1.0 - 2015-xx-xx ( xxxxx ): first created.
*/
Let ( [
privSetSuffix = GetAsNumber ( Right ( Get ( AccountPrivilegeSetName ); 1 ) )
];
/* check privSet suffix, and use it if 1 or 2 */
Case (
privSetSuffix = 1;
1;
privSetSuffix = 2;
2;
/* DEFAULT: if none of the above, try accountName suffix, and fail to orgNum 1 */
Let ( [
accountNameSuffix = GetAsNumber ( Right ( Get ( AccountName ); 1 ) )
];
Case (
/* check account name suffix */
accountNameSuffix = 1;
1;
accountNameSuffix = 2;
2;
/* unable to get it based on privSet and accountName, so default to 1 */
1
)
)
)
)]]>
</Calculation>
</CustomFunction>
</fmxmlsnippet>