I've created doc type with property e.g. (Name = "ItemId" Type = "Label")
When i try to "Save and Publish" node with current doc type i set some value to this label. (note that i override SendAsync method)
It sets value correctly, but label still appears to be empty. So if i click on "Save and Publish" second time it sends an empty value still... I need somehow to refresh page because on second time i need "guidvalue" to update other items
protected async override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
var path = request.RequestUri.AbsolutePath.ToLower();
switch (path)
{
case "/umbraco/backoffice/umbracoapi/content/postsave":
return await SaveEvent(request, cancellationToken);
default:
return await base.SendAsync(request, cancellationToken);
}
}
private Task<HttpResponseMessage> SaveEvent(HttpRequestMessage request, CancellationToken cancellationToken)
{
return base.SendAsync(request, cancellationToken)
.ContinueWith(task =>
{
var response = task.Result;
HttpContent data = null;
ContentItemDisplay content = null;
try
{
data = response.Content;
content = ((ObjectContent)(data)).Value as ContentItemDisplay;
if (content.ContentTypeAlias.ToLower() == "DocTypeAlias")
{
var cs = ApplicationContext.Current.Services.ContentService;
var currentEvent = cs.GetById((int)content.Id);
currentEvent.SetValue("LabelAlias", "guidvalue");
}
}
It sets the value for LabelAlias in DB, but page still shows an empty value and on second press "Save and Publish" i got an empty value.
That's why i need to refresh the page to get "guidvalue" in label data type
Have you considered using an HTTP interceptor to update the values before they hit the server? You should be able to catch the request to /postSave, then modify the data model.
Not sure though if that will impact the displayed value in the data type
Refresh Page On Save And Publish
Hi,
I've created doc type with property e.g. (Name = "ItemId" Type = "Label") When i try to "Save and Publish" node with current doc type i set some value to this label. (note that i override SendAsync method)
currentContent.SetValue("ItemIdAlias","guidvalue");
It sets value correctly, but label still appears to be empty. So if i click on "Save and Publish" second time it sends an empty value still... I need somehow to refresh page because on second time i need "guidvalue" to update other items
Hi, Can you post some code to explain how you're setting the value?
Hi Robert,
Thanks for your response. Sure.
It sets the value for LabelAlias in DB, but page still shows an empty value and on second press "Save and Publish" i got an empty value. That's why i need to refresh the page to get "guidvalue" in label data type
Did you find a solution to this in the end?
Have you considered using an HTTP interceptor to update the values before they hit the server? You should be able to catch the request to /postSave, then modify the data model.
Not sure though if that will impact the displayed value in the data type
Yeah it seem like the only option I could do. I had to re render the datapicker to display the changes.
is working on a reply...