Acumatica:如何在通用查询中获取当前短日期和长时间格式?

问题描述:

我们使用Acumatica WEB API来运行GI;但有时DateTime参数不起作用,因为运行GI的一侧与用户登录本地化的de本地化设置不匹配。Acumatica:如何在通用查询中获取当前短日期和长时间格式?

之前运行GI,我需要阅读的用户偏好的本地化或网站默认本地化(用户HAZ自己的本地化设置无法访问)

到目前为止,我已经找到了获取当前的方式用户登录和下表:

_UserSide_ 
Users->UserPreferences 
UserPreferences->UserLocaleFormat 
UserLocaleFormat->LocaleFormat 

_SiteDefault_ 
Locale->LocaleFormat 

我走得更远之前...是任何简单的方式来获得在GI的loged用户目前本地化?

因为我为FormatID字段得到了一些奇怪的ID。

找到了解决办法,以获得当前登录用户的区域设置日期时间模式:

当用户访问自己的个人资料中,localitation来自: 用户 - > UserPreferences-> UserLocaleFormat-> LocalFormat

当用户不能访问自己的个人资料或为空白: Locale-> LocaleFormat(其中Locale.IsActive =真实Locale.IsDefault =真)

这里是Acumatica诉GI 6.0。 (注意这将重新标记GI惠特ID GI00000001)

<?xml version="1.0" encoding="utf-8" standalone="yes"?> 
<data-set> 
    <relations format-version="3" relations-version="20160530" main-table="GIDesign"> 
    <link from="GIFilter (DesignID)" to="GIDesign (DesignID)" /> 
    <link from="GIGroupBy (DesignID)" to="GIDesign (DesignID)" /> 
    <link from="GIMassAction (DesignID)" to="GIDesign (DesignID)" /> 
    <link from="GIMassUpdateField (DesignID)" to="GIDesign (DesignID)" /> 
    <link from="GINavigationScreen (DesignID)" to="GIDesign (DesignID)" /> 
    <link from="GINavigationParameter (DesignID, ScreenID)" to="GINavigationScreen (DesignID, ScreenID)" /> 
    <link from="GIOn (DesignID, RelationNbr)" to="GIRelation (DesignID, LineNbr)" /> 
    <link from="GIRecordDefault (DesignID)" to="GIDesign (DesignID)" /> 
    <link from="GIRelation (DesignID, ParentTable)" to="GITable (DesignID, Alias)" /> 
    <link from="GIRelation (DesignID, ChildTable)" to="GITable (DesignID, Alias)" /> 
    <link from="GIResult (DesignID)" to="GIDesign (DesignID)" /> 
    <link from="GIResult (ObjectName, DesignID)" to="GITable (Alias, DesignID)" /> 
    <link from="GISort (DesignID)" to="GIDesign (DesignID)" /> 
    <link from="GITable (DesignID)" to="GIDesign (DesignID)" /> 
    <link from="GIWhere (DesignID)" to="GIDesign (DesignID)" /> 
    <link from="SiteMap (Url)" to="GIDesign (DesignID)" type="WeakByUrl" linkname="toDesignById" baseurl="~/GenericInquiry/GenericInquiry.aspx" paramnames="id" /> 
    <link from="SiteMap (Url)" to="GIDesign (Name)" type="WeakByUrl" linkname="toDesignByName" baseurl="~/GenericInquiry/GenericInquiry.aspx" /> 
    <link from="ListEntryPoint (ListScreenID)" to="SiteMap (ScreenID)" /> 
    <link from="SiteMap (ScreenID)" to="GIDesign (PrimaryScreenIDNew)" linkname="to1Screen" /> 
    <link from="SiteMap (NodeID)" to="SiteMap (ParentID)" type="WeakToParent" recursive-nesting="yes" include-parents="False" /> 
    <link from="GIDesign (NoteID)" to="Note (NoteID)" type="Note" /> 
    <link from="GIFilter (NoteID)" to="Note (NoteID)" type="Note" /> 
    <link from="GIFilter (NoteID)" to="GIFilterKvExt (RecordID)" type="RowKvExt" /> 
    <link from="GIGroupBy (NoteID)" to="Note (NoteID)" type="Note" /> 
    <link from="GIOn (NoteID)" to="Note (NoteID)" type="Note" /> 
    <link from="GIRelation (NoteID)" to="Note (NoteID)" type="Note" /> 
    <link from="GIResult (NoteID)" to="Note (NoteID)" type="Note" /> 
    <link from="GIResult (NoteID)" to="GIResultKvExt (RecordID)" type="RowKvExt" /> 
    <link from="GISort (NoteID)" to="Note (NoteID)" type="Note" /> 
    <link from="GITable (NoteID)" to="Note (NoteID)" type="Note" /> 
    <link from="GIWhere (NoteID)" to="Note (NoteID)" type="Note" /> 
    </relations> 
    <layout> 
    <table name="GIDesign"> 
     <table name="GIFilter" uplink="(DesignID) = (DesignID)"> 
     <table name="Note" uplink="(NoteID) = (NoteID)" /> 
     <table name="GIFilterKvExt" uplink="(NoteID) = (RecordID)" /> 
     </table> 
     <table name="GIGroupBy" uplink="(DesignID) = (DesignID)"> 
     <table name="Note" uplink="(NoteID) = (NoteID)" /> 
     </table> 
     <table name="GIMassAction" uplink="(DesignID) = (DesignID)" /> 
     <table name="GIMassUpdateField" uplink="(DesignID) = (DesignID)" /> 
     <table name="GINavigationScreen" uplink="(DesignID) = (DesignID)"> 
     <table name="GINavigationParameter" uplink="(DesignID, ScreenID) = (DesignID, ScreenID)" /> 
     </table> 
     <table name="GIRecordDefault" uplink="(DesignID) = (DesignID)" /> 
     <table name="GISort" uplink="(DesignID) = (DesignID)"> 
     <table name="Note" uplink="(NoteID) = (NoteID)" /> 
     </table> 
     <table name="GITable" uplink="(DesignID) = (DesignID)"> 
     <table name="GIRelation" uplink="(DesignID, Alias) = (DesignID, ParentTable)"> 
      <table name="GIOn" uplink="(DesignID, LineNbr) = (DesignID, RelationNbr)"> 
      <table name="Note" uplink="(NoteID) = (NoteID)" /> 
      </table> 
      <table name="Note" uplink="(NoteID) = (NoteID)" /> 
     </table> 
     <table name="GIResult" uplink="(Alias, DesignID) = (ObjectName, DesignID)"> 
      <table name="Note" uplink="(NoteID) = (NoteID)" /> 
      <table name="GIResultKvExt" uplink="(NoteID) = (RecordID)" /> 
     </table> 
     <table name="Note" uplink="(NoteID) = (NoteID)" /> 
     </table> 
     <table name="GIWhere" uplink="(DesignID) = (DesignID)"> 
     <table name="Note" uplink="(NoteID) = (NoteID)" /> 
     </table> 
     <table name="SiteMap" uplink="(DesignID) = (Url)" recursion="(NodeID) = (ParentID)" linkname="toDesignById"> 
     <table name="ListEntryPoint" uplink="(ScreenID) = (ListScreenID)" /> 
     </table> 
     <table name="SiteMap" uplink="(Name) = (Url)" recursion="(NodeID) = (ParentID)" linkname="toDesignByName"> 
     <table name="ListEntryPoint" uplink="(ScreenID) = (ListScreenID)" /> 
     </table> 
     <table name="SiteMap" uplink="(PrimaryScreenIDNew) = (ScreenID)" recursion="(NodeID) = (ParentID)" linkname="to1Screen"> 
     <table name="ListEntryPoint" uplink="(ScreenID) = (ListScreenID)" /> 
     </table> 
     <table name="Note" uplink="(NoteID) = (NoteID)" /> 
    </table> 
    </layout> 
    <data> 
    <GIDesign> 
     <row DesignID="5f1395b0-a36e-479a-8911-2ad48d885bde" Name="ITOS_GI_Heartbeat" SelectTop="1" FilterColCount="3" PagerStyle="0" PageSize="0" NewRecordCreationEnabled="0" MassDeleteEnabled="0" AutoConfirmDelete="0" MassRecordsUpdateEnabled="0" MassActionsOnRecordsEnabled="0" ExposeViaOData="0"> 
     <GIFilter LineNbr="1" IsActive="0" Name="Username" FieldName="Users.username" DataType="string" DisplayName="Username" IsExpression="0" DefaultValue="Admin" ColSpan="1" Required="0"> 
      <GIFilterKvExt FieldName="DisplayNameEN" ValueText="Username" /> 
     </GIFilter> 
     <GISort LineNbr="6" IsActive="1" DataFieldName="LocaleFormat.formatID" SortOrder="D" /> 
     <GITable Alias="Locale" Name="PX.SM.Locale"> 
      <GIResult LineNbr="7" IsActive="0" Field="localeName" Caption="L LoacaleName" IsVisible="1" DefaultNav="1"> 
      <GIResultKvExt FieldName="CaptionEN" ValueText="L LoacaleName" /> 
      </GIResult> 
      <GIResult LineNbr="14" IsActive="0" Field="formatID" Caption="L FormatID" IsVisible="1" DefaultNav="1"> 
      <GIResultKvExt FieldName="CaptionEN" ValueText="L FormatID" /> 
      </GIResult> 
     </GITable> 
     <GITable Alias="LocaleFormat" Name="PX.SM.LocaleFormat"> 
      <GIResult LineNbr="3" IsActive="1" Field="dateShortPattern" Caption="ULFLocaleNaqme" IsVisible="1" DefaultNav="1"> 
      <GIResultKvExt FieldName="CaptionEN" ValueText="DateShortPattern" /> 
      <GIResultKvExt FieldName="CaptionES" ValueText="ULFLocaleNaqme" /> 
      </GIResult> 
      <GIResult LineNbr="4" IsActive="1" Field="timeLongPattern" Caption="DateShort" IsVisible="1" DefaultNav="1"> 
      <GIResultKvExt FieldName="CaptionEN" ValueText="TimeLongPattern" /> 
      <GIResultKvExt FieldName="CaptionES" ValueText="DateShort" /> 
      </GIResult> 
      <GIResult LineNbr="5" IsActive="1" Field="templateLocale" Caption="TimeLong" IsVisible="1" DefaultNav="1"> 
      <GIResultKvExt FieldName="CaptionEN" ValueText="LocaleName" /> 
      <GIResultKvExt FieldName="CaptionES" ValueText="TimeLong" /> 
      </GIResult> 
      <GIResult LineNbr="11" IsActive="0" Field="templateLocale" Caption="LF TemplateLocale" IsVisible="1" DefaultNav="1"> 
      <GIResultKvExt FieldName="CaptionEN" ValueText="LF TemplateLocale" /> 
      </GIResult> 
      <GIResult LineNbr="13" IsActive="0" Field="formatID" Caption="LF FormatID" IsVisible="1" DefaultNav="1"> 
      <GIResultKvExt FieldName="CaptionEN" ValueText="LF FormatID" /> 
      </GIResult> 
     </GITable> 
     <GITable Alias="LoginTrace" Name="PX.SM.LoginTrace"> 
      <GIRelation LineNbr="3" ChildTable="Users" IsActive="1" JoinType="I"> 
      <GIOn LineNbr="12" ParentField="username" Condition="E " ChildField="username" Operation="A" /> 
      </GIRelation> 
      <GIResult LineNbr="1" IsActive="1" Field="=Concat(CStr(Year(Now())), PadRight(CStr(Month(Now())),2,'0'), PadRight(CStr(Day(Now())),2,'0'), PadRight(CStr(Hour(Now())),2,'0'),PadRight(CStr(Minute(Now())),2,'0'), PadRight(CStr(Second(Now())),2,'0'))" Caption="Today" IsVisible="1" DefaultNav="1"> 
      <GIResultKvExt FieldName="CaptionEN" ValueText="NowWindev" /> 
      <GIResultKvExt FieldName="CaptionES" ValueText="Today" /> 
      </GIResult> 
      <GIResult LineNbr="2" IsActive="1" Field="=Now()" Caption="Now" IsVisible="1" DefaultNav="1"> 
      <GIResultKvExt FieldName="CaptionEN" ValueText="NowAcumatica" /> 
      <GIResultKvExt FieldName="CaptionES" ValueText="Now" /> 
      </GIResult> 
     </GITable> 
     <GITable Alias="UserLocaleFormat" Name="PX.SM.UserLocaleFormat"> 
      <GIRelation LineNbr="7" ChildTable="LocaleFormat" IsActive="1" JoinType="L"> 
      <GIOn LineNbr="22" ParentField="UserLocaleFormat.formatID" Condition="E " ChildField="formatID" Operation="O" /> 
      <GIOn LineNbr="23" ParentField="Locale.formatID" Condition="E " ChildField="formatID" Operation="O" /> 
      </GIRelation> 
      <GIResult LineNbr="6" IsActive="0" Field="localeName" Caption="User" IsVisible="1" DefaultNav="1"> 
      <GIResultKvExt FieldName="CaptionEN" ValueText="ULF LocaleName" /> 
      <GIResultKvExt FieldName="CaptionES" ValueText="User" /> 
      </GIResult> 
      <GIResult LineNbr="9" IsActive="0" Field="userID" Caption="ULF UserID" IsVisible="1" DefaultNav="1"> 
      <GIResultKvExt FieldName="CaptionEN" ValueText="ULF UserID" /> 
      </GIResult> 
      <GIResult LineNbr="12" IsActive="0" Field="formatID" Caption="ULF FormatID" IsVisible="1" DefaultNav="1"> 
      <GIResultKvExt FieldName="CaptionEN" ValueText="ULF FormatID" /> 
      </GIResult> 
     </GITable> 
     <GITable Alias="UserPreferences" Name="PX.SM.UserPreferences"> 
      <GIRelation LineNbr="6" ChildTable="UserLocaleFormat" IsActive="1" JoinType="F"> 
      <GIOn LineNbr="24" ParentField="userID" Condition="E " ChildField="userID" Operation="A" /> 
      </GIRelation> 
      <GIResult LineNbr="8" IsActive="0" Field="userID" Caption="UserPreferences UserID" IsVisible="1" DefaultNav="1"> 
      <GIResultKvExt FieldName="CaptionEN" ValueText="UserPreferences UserID" /> 
      </GIResult> 
     </GITable> 
     <GITable Alias="Users" Name="PX.SM.Users"> 
      <GIRelation LineNbr="4" ChildTable="Locale" IsActive="1" JoinType="L"> 
      <GIOn LineNbr="26" ParentField="isOnLine" Condition="E " ChildField="isDefault" Operation="A" /> 
      <GIOn LineNbr="27" ParentField="isOnLine" Condition="E " ChildField="isActive" Operation="A" /> 
      </GIRelation> 
      <GIRelation LineNbr="5" ChildTable="UserPreferences" IsActive="1" JoinType="I"> 
      <GIOn LineNbr="25" ParentField="pKID" Condition="E " ChildField="userID" Operation="A" /> 
      </GIRelation> 
      <GIResult LineNbr="10" IsActive="0" Field="username" Caption="Users Username" IsVisible="1" DefaultNav="1"> 
      <GIResultKvExt FieldName="CaptionEN" ValueText="Users Username" /> 
      </GIResult> 
     </GITable> 
     <GIWhere LineNbr="1" IsActive="0" DataFieldName="Users.username" Condition="E " IsExpression="0" Value1="[Username]" Operation="A" /> 
     <GIWhere LineNbr="2" IsActive="1" DataFieldName="Users.isOnLine" Condition="E " IsExpression="1" Value1="True" Value2="False" Operation="A" /> 
     <GIWhere LineNbr="3" IsActive="1" DataFieldName="LoginTrace.screenID" Condition="E " IsExpression="1" Value1="GI000001" Operation="A" /> 
     <GIWhere LineNbr="5" IsActive="1" OpenBrackets="((  " DataFieldName="UserLocaleFormat.userID" Condition="NU" IsExpression="0" CloseBrackets=")  " Operation="O" /> 
     <GIWhere LineNbr="6" IsActive="1" OpenBrackets="(  " DataFieldName="UserLocaleFormat.userID" Condition="NN" IsExpression="0" Operation="A" /> 
     <GIWhere LineNbr="7" IsActive="1" DataFieldName="UserLocaleFormat.formatID" Condition="NN" IsExpression="0" Operation="A" /> 
     <GIWhere LineNbr="8" IsActive="1" DataFieldName="LocaleFormat.formatID" Condition="E " IsExpression="0" Value1="UserLocaleFormat.FormatID" CloseBrackets="))  " Operation="A" /> 
     <SiteMap linkname="toDesignById"> 
      <row Position="59" Title="ITOS GI Heartbeat" Url="~/GenericInquiry/GenericInquiry.aspx?id=5f1395b0-a36e-479a-8911-2ad48d885bde" Expanded="0" IsFolder="0" ScreenID="GI000001" NodeID="00bdd816-dcb2-44b5-b0e0-83f608e35d9f" ParentID="702a9fc5-bf44-4421-b339-4c2da7a32582"> 
      <SiteMap Position="127" Title="Consultas Generales" Expanded="0" IsFolder="0" NodeID="702a9fc5-bf44-4421-b339-4c2da7a32582"> 
       <SiteMap Position="589" Title="Work Area" Description="[email protected]" Expanded="1" IsFolder="0" NodeID="de0d5687-3c67-4ec7-94e9-2c3e5225f817"> 
       <SiteMap Position="516" Title="Sales Orders" Url="~/Frames/Default.aspx" Expanded="0" IsFolder="0" ScreenID="SO000000" NodeID="ff2d3fd4-ab02-43c9-ad02-aad212542770"> 
        <SiteMap Position="30" Title="Distribution" Url="~/Frames/Default.aspx" Expanded="0" IsFolder="0" ScreenID="DS000000" NodeID="91d578ba-75b6-4fa9-a532-9457a6383a62"> 
        <SiteMap Position="0" Title="Sitemap Root" Url="~/Frames/Default.aspx" Expanded="0" IsFolder="0" ScreenID="00000000" NodeID="00000000-0000-0000-0000-000000000000" /> 
        </SiteMap> 
       </SiteMap> 
       </SiteMap> 
      </SiteMap> 
      </row> 
     </SiteMap> 
     <Note NoteText="Now(): Returns the current date and time according to the system date and time on the local computer.&#xA;&#xA;NowUTC(): Returns the current date and time according to the user’s time zone.&#xA;The system gets the user’s time zone from the following sources, which are ordered by the priority from the highest to the lowest:&#xA;&#xA;1. User’s preferences specified on the User Profile (SM.20.30.10) form.&#xA;2. The employee calendar specified on the Work Calendar (CS.20.90.00) form and selected for the user's employee on the Employees (EP.20.30.00) form.&#xA;3. Site preferences specified on the on the Site Preferences (SM.20.05.05) form." GraphType="PX.Data.Maintenance.GI.GenericInquiryDesigner" EntityType="PX.Data.Maintenance.GI.GIDesign" /> 
     </row> 
    </GIDesign> 
    </data> 
</data-set>