Retrieve query for time range (FetchXML/QueryExpression) - datetime

(Sorry for bad English)
I have an application that uses MS-CRM 2011 Web Service for retrieving last changes on crm Entities. This application Sync last data changes with a Windows Mobile device.
Sync operation occurs periodic every 20 minutes. In each sync operation I want to retrieve changes occurred from previous update by checking entities 'modifiedon' field.
Problem is that, CRM queries don't use Time piece of DateTime object and all change from the start of passed DateTime parameter been returned.
I'd check both FetchXML and QueryExpression, there is no different.
Is there any way to create a query for run on Crm WebService that return modified record from specified Date and time?
Sample (My FetchXml) :
<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
<entity name='new_brand'>
<attribute name='new_brandname' />
<attribute name='new_pdanumber' />
<filter type='and'>
<condition attribute='modifiedon' operator='on-or-after' value='2012/11/12 23:59'/>
</filter>
</entity>
</fetch>
See In the code, I wants all modified entities from 2012/11/12 23:00, but crm returns all modified record from 2012/11/12 00:00.

I have the same problem now with and oldest Dynamics CRM 2011 organization.The on or after comparation don't compare the time, only the date. Try using grater or equal ('ge' in fetchxml).

Your code is looking for records changed on or after 23:59... Your documented results sound correct.
In any case, the time part is used but i suspect you are seeing the result of user time versus universal time. If the users time zone offset != 0 then midnight as selected by the user in the UI will be different to the value stored in the database which is the UST equivalent.

We've added a new field (called ModifiedOnTick) to the Entity, and record the time difference in milliseconds with a fixed date (2011-01-01) in this field.

Related

D365 FO Simple Query for expiring contract

I need to create simple query which will show all contracts which will expire in next 3 months. I know how to do that with SQL, but how to do that in Visual Studio when I create query. I added data source Contract table. Added range. Column where is date about expiring is VALIDTO.
So, something to write up in value, or how to do that ?
Solved with two ranges on VALIDTO column. Used (MonthRange(0,3)) with (Day(0)) formulas.

Powerapps - get stuck with UpdateContext

I am trying to build a PowerApp to log setup times of our machines by our fitters.
This is what my app looks like:
There are buttons named "Uhrzeit". Pressing these will write the current date and time into the Date/Time fields. I am using the following code:
UpdateContext({Total8:(Text( Now(); "[$-de-DE]dd/mm/yyyy hh:mm:ss" ))})
The Date/Time field is named Total8.
The code is working well but after saving the form and opening a new record the old data is still available in the fields. By clicking on the button "Zeiten zurücksetzen" I can "delete" the old data.
UpdateContext({Total8:""})
Problem: When I open one of the older records the old data is not available in the form. There is only the value of the last record. In the Common Data Service where my records are saved the values are correct.
As an example, I am saving this record:
When I open a new record, the values of the record 1 are still available. This should not be the case if my app worked properly.
For your Information:
If I enter the date/time without tapping the button, saving the record and opening a new record I don't have the problem. I think the "UpdateContext" code is not the code I should use here.
Can anyone help me solve the problem?
I don't think there's a problem with using the contexts in this way -- but remember that a context is just a variable. It isn't automatically linked to a datasource in any special way - so if you set it equal to Now(), it's going to keep that value until you do something different.
When you view an old record, you need to get the data from CDS and update your contexts to match the CDS data. Does this make sense?
Yeah thats my problem.
I want the variable to be linked to a datasource. Or is it possible to write the date/time into the fields without using a context variable?

Database table in which WTPart or Change activity Maturity History is stored

I need to pull the date on which a WTPart was in inwork state or A CN was in published state.
I did my analysis and found that there should be a Maturity history table in database, but i ended up with a table called MaturityBaseline table which does not hold this information. I need guidance on which table this information is stored. Even in API com.ptc.windchill.enterprise.history.HistoryTablesCommands.maturityHistory(wtObject); they are using Maturity History class.
Have you tried this method from same class?
com.ptc.windchill.enterprise.history.HistoryTablesCommands.getLegacyLifeCycleHistory(LifeCycleManaged arg0);
I have never tried by myself though. Also check for HistoryRecord table in database whether it have any info related to this.
I know this question is may years old now, but I stumbled across it looking at how to find the history of a change issue/problem report.
My problem report has a number TA00025 and I want to find when it was completed. The enter_phase action will tell me whenever the state has changed. This SQL will tell me changes of state for the nominated change issue/problem report (the same object type in Windchill)
select LH.action, LH.state, LH.updateStampA2
from wcadmin.[wcadmin].ObjectHistory OH, wcadmin.[wcadmin].LifeCycleHistory LH,
wcadmin.wcadmin.WTChangeIssueMaster CIM, wcadmin.wcadmin.WTChangeIssue CI
where OH.idA3A5 = CI.idA2A2
and OH.idA3B5 = LH.idA2A2
and CI.idA3masterReference = CIM.idA2A2
and CIM.WTCHGISSUENUMBER = 'TA00025'
and LH.action = 'Enter_Phase'
For a WTPart the history all sits in the table WTPart which will have a full history for a part wth multiple records.

How can I attach a datarule to a data broker's key-generation operation?

I have a Workflow SQL databroker in which the ID field is a sequential number with additional character padding, i.e. P001 or TM234.
I have defined the query for ID generation as:
<key-generation field="id" query="queries/asset-patent-get-id" />
which simply retrieves next sequence value based on provided parameters. So for every created record I need to make sure that by the time ID gets stored in database it was already padded as per required rules and stored as a string rather than just a number.
First thing to note: a data rule isn't bound to an operation, but instead to a field. So in this case, just think of the key-generation operation as retrieving the next number in a sequence, nothing more. Once the sequence value is retrieved, an appropriate bound data rule should be able to format the sequence value before it is persisted.
You should be able to define a data rule something like this:
<!-- datarules/format-asset-patent-id/definition.xml -->
<data-rule name="format-asset-patent-id"
factory-class="com.aviarc.framework.datarule.xml.DefaultXMLDataRuleProviderFactoryImpl"
datarule-class="com.aviarc.framework.datarule.workflow.WorkflowDataRule">
<parameters>
<parameter name="field" mandatory="y"/>
</parameters>
<event name="onBeforeDatasetPersisted" workflow="workflows/format-asset-patent-id" field="{#field}"/>
</data-rule>
Then in the format-asset-patent-id workflow you can take care of formatting the id. (Note: I haven't had the chance to test whether the onBeforeDatasetPersisted event fires before or after the key-generation operation is performed.)
Then you could bind it with a data binding, for example:
<!-- databindings/asset-patent.xml -->
<databinding databroker="asset-patent"
factory-class="com.aviarc.framework.databinding.basic.BasicDataBindingFactoryImpl">
<on-dataset-bound>
<data-rules>
<format-asset-patent-id field="id"/>
</data-rules>
</on-dataset-bound>
</databinding>

Programatically check if a date-period has expired and possibly add new row to a table, daily

I have a table, named ReportingPeriods, that I want to be populated entirely automatically. In another table, there are attributes CreationDate and ReportingPeriodLength which together will determine the the results of this row. Upon adding a row for this table, we will add a row in ReportingPeriods with the first StartDate as the creation date and EndDate as ReportingPeriodLength days after startDate.
So far, this is simple. However, I wish to check (daily) whether this period has expired. And if it has, I want to start a new row, beginning the day after the EndDate and extending, once again, for ReportingPeriodLength days.
Is this possible to accomplish without manually checking and adding a new row?
Thanks :)
call a stored procedure from a database job that is run each day. within this procedure, do your check and insert if necessary.
Windows Scheduled Tasks is an appropriate tool for this.
You can write a simple script or a C# console application that calls a stored procedure in your database. Add that executable as the command for a new scheduled task and pick an appropriate time.

Resources