Retrieve only left, right, propertyName from the javers Change class - javers

I am using the following code to retreive the changes made to a version in my API response
List<Change> versionChanges = javers.findChanges(jqlQuery.build()).groupByCommit()get(0).get()
It gave me the following
https://user-images.githubusercontent.com/10185101/122550135-f3223b00-d050-11eb-9cc8-72982808cd2e.png
But I don't want this entire data to go as my API response
I just want to isolate left, right, propertyName in my response
I am not able to find an API on Change.class that can do me so ..
How can I achieve this
Thank you

List<ChangesByCommit> changes = javers.findChanges(jqlQuery.build()).groupByCommit();
ValueChange valueChange = (ValueChange)changes.get(0).get().get(0);
String property = valueChange.getPropertyName();
Object originalValue = valueChange.getLeft();
Object newValue = valueChange.getRight();

Related

XrmServiceContext object is not getting the latest data from CRM

i have a wcf which connects to crm (on prem) to retrieve an account record. i can see when the entity is retrieved it does not hold the current record i.e. some field will still hold the old column value. i tried with various merge option with no avail. please see the code below
using (XrmServiceContext cContext = new XrmServiceContext(con))
{
Entity ent = cContext.Retrieve(ConstantKVP.AccountSchema.ENTITY_LOGICAL_NAME, AccountId, new ColumnSet(true));
}
any suggestions?
Is it possible the data is being cached?
cContext.TryAccessCache(cache => cache.Mode = OrganizationServiceCacheMode.Disabled);
I took this approach for a CrmOrganizationServiceContext, so perhaps the same theory applies.
After save use clear changes cContext.ClearChanges();
For retrieves use MergeOption.OverwriteChanges
Or
Create a new XrmServiceContext object by passing a newed up organizationservice:
var uncachedOrganizationService = new OrganizationService("Xrm");
var uncachedXrmServiceContext = new XrmServiceContext(uncachedOrganizationService);
var ent = uncachedXrmServiceContext.Retrieve(ConstantKVP.AccountSchema.ENTITY_LOGICAL_NAME,AccountId,new ColumnSet(true));

Send boolean to Parse

In Parse I have a class that has a string and a boolean column.
I want to update the object with new values and I do this:
RestSharp client =...
RestRequest request = new RestRequest(Method.PUT);
request.AddParameter("String column", "new string");
request.AddJsonBody("{"+"Boolean column"+":False\"}");
request.RequestFormat = DataFormat.Json;
var requestHandler = client.ExecuteAsync(...)
The response's status is OK and when I check with Parse dashboard on the server, the first column has changed. But the second column, the boolean one has not changed.
How should I set the boolean parameter?
I tried:
request.AddJsonBody("{"+"Boolean column"+":false\"}");
request.AddJsonBody("{"+"Boolean column"+":0\"}");
but none of them changed the value on the backend server.
When I tried:
request.AddParameter("Boolean column": false);
I got this error:
"{\"code\":111,\"error\":\"schema mismatch for ...; expected Boolean but got String\"}"
How can I fix this problem?
Thank you
check your mongodb collection 'SCHEMA' for the answer
Because the Parse will create a restricted condition according to the first record inserted for each collection.

Receiving null parameters from request in JSP file when are being sent

I've a JSP app. It uploads a file, but to do so the user has to authenticate using a name and a password. So my JSP file starts with:
//0.2.- We get the password
String password = (String) request.getParameter("pass"); // -> This returns NULL
//0.3.- We get the "uvus"
String uvus = (String) request.getParameter("uvus"); //-> This also returns NULL
//More code
So I'm trying to know why am I getting null from those variables.
I went to the form I was uploading, and look for the data that was being sent. Using Firefox Debug Tools, I saw:
So in fact, it was being sent.
As additional info, I'm building the request like this:
var pUvus = document.getElementById("uvus").value;
var pPassword = document.getElementById("pass").value;
var file = document.getElementById("userFile");
var formData = new FormData();
formData.append("upload", file.files[0]);
formData.append("uvus", pUvus);
formData.append("pass", pPassword);
xmlhttp.open("POST","uploadFile.jsp",true);
xmlhttp.send(formData);
At last, I would like to say that I can get vars from application object in the same JSP with no errors, and have received in another pair of JSP files vars at request object without more problems, so I think my fault should be in the way I'm building the request in Ajax, but I've no more clue about that...
Anyone can guide me?
Thanks for your help
Update: #rickz asked for how do I get the file and parse the request (what is done after my problem, trying to get the objects from the request scope):
List items;
items = servlet_up.parseRequest(request);
for(int i=0;i<items.size();i++)
{
FileItem item = (FileItem) items.get(i);
if (! item.isFormField())
{
request.getParameter() won't work for a multipart/form-data request.
If you are using org.apache.commons.fileupload then you should be using something like
if(item.isFormField()){
name = item.getFieldName();
...
}

Visit a URL with a variable altering the url, windows phone

I have a URL that is shown below:
URL is taken out due to contract reasons
WebClient webClient = new WebClient();
Uri uri = new Uri("http://www.URLhere.aspx?stopid=4556");
webClient.OpenReadCompleted += new OpenReadCompletedEventHandler
(webClient_OpenReadCompleted);
webClient.OpenReadAsync(uri);
I need to find a way to alter the end part, so change 4556 from a text block, into another text so that when the application send the request it finds the whole lot.
I thought you could do this:
WebClient webClient = new WebClient();
Uri uri = new Uri("http://www.URLhere.aspx?stopid=" + stopId);
webClient.OpenReadCompleted += new OpenReadCompletedEventHandler
(webClient_OpenReadCompleted);
webClient.OpenReadAsync(uri);
How does one do this?
Edit:
When i do the code above it returns as a null reference, so i am asuming it's not getting the text in the textbox.
It sounds like you're missing the encoding of your variable.
var myvar = "the simpsons";
Uri myUri = new Uri("http://www.URLhere.aspx?stopid=" + HttpUtility.UrlEncode(myvar));
See HttpUtility.UrlEncode Method - MSDN
there is no difference between
Uri uri = new Uri("http://www.URLhere.aspx?stopid=4556");
and
Uri uri = new Uri("http://www.URLhere.aspx?stopid=" + stopId);
so i really don't know whats your problem
Henry,
If I understand you question correctly, I think you want to append the value in a TextBox (not a TextBlock) to the URI. If that is correct and you're employing MVVM, you could bind your TextBox to a public property on the ViewModel (lets call it TextBoxProp)
private string _textBoxProp;
public string TextBoxProp
{
get{return _textBoxProp;}
set
{
_textBoxProp = value;
RaisePropertyChanged("TextBoxProp");
}
}
and then create your URI as follows:
Uri uri = new Uri(String.Format("http://www.URLhere.aspx?stopid={0}", TextBoxProp));
Be sure when you bind to the property in XAML that you set the mode to TwoWay.
I hope that helps

LINQ CRM 2011 Update - Create

I notice the the CRM moderator David Jennaway on the technet forum states that you can't use LINQ to update/Create records in CRM 2011 see here http://social.microsoft.com/Forums/en-IE/crmdevelopment/thread/682a7be2-1c07-497e-8f58-cea55c298062
But I have seen a few threads that make it seem as if it should work. Here is my attempt which doesn't work. Any ideas why not?
IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);
OrganizationServiceContext orgContext = new OrganizationServiceContext(service);
EntityState state = new EntityState();
state = EntityState.Changed;
var counter = from c in orgContext.CreateQuery<pcx_entitycounter>()
where c.pcx_name.Contains("pcx_candidate")
select new pcx_entitycounter
{Id = c.Id,
pcx_name = c.pcx_name, pcx_Sequence = c.pcx_Sequence, pcx_Prefix = c.pcx_Prefix
};
foreach (var c in counter)
{
string prefix = c.pcx_Prefix.ToString(); ;
string sequence = c.pcx_Sequence.ToString();
c.pcx_Sequence = c.pcx_Sequence + 1;
c.EntityState = state;
**service.Update(c);** //FAILS HERE
}
In my experience, it's been difficult-to-impossible to retrieve an entity from the Context, update it, then use the Service to save the changes. It has caused me headaches figuring it out!
Since your retrieval code uses a query from the Context, all of those entities should be attached to the Context and their states are being tracked. Thus you need to use the Context's method for updating:
foreach (var c in counter) {
string prefix = c.pcx_Prefix.ToString(); ;
string sequence = c.pcx_Sequence.ToString();
c.pcx_Sequence = c.pcx_Sequence + 1;
// Use the Context to save changes
orgContext.UpdateObject(c);
orgContext.SaveChanges();
}
Since a lot of my code will retrieve entities in different ways (i.e. Service or Context) depending on the situation, I have developed a simple method that knows how to update the entity correctly. To expand on your example, you might have an update method that looks like:
public void UpdatePcxEntityCounter(pcx_entitycounter c) {
if (!orgContext.IsAttached(c)) {
service.Update(c);
}
else {
orgContext.UpdateObject(c);
orgContext.SaveChanges();
}
}
This assumes both orgContext and service are available at a scope above that of the method. Otherwise, they'd have to be passed as additional parameters.
Without seeing the difficult its difficult to discern what the issue is but have you tried using orgContext.UpdateObject(c); before doing the update step? Also, not sure why you are assigning the prefix and sequence to local variables within your loop since they don't appear to be being used. Its possible that you are getting a SOAP Exception or something for assigning values that don't work. Do you have any plugins registered on the entity?
See the following links for possible resolutions -
How to update a CRM 2011 Entity using LINQ in a Plugin?
http://social.microsoft.com/Forums/en-US/crmdevelopment/thread/7ae89b3b-6eca-4876-9513-042739fa432a

Resources