Uni selector not picking up changes in the field

paul krysiak asked on October 10, 2017 19:34

Hello Everyone
I made a program to remap page types from one folder to another. I checked the format the values were being stored in the database and i found that it is a guid deliminated with a ;. The program does update the database valuse correctly but i find the Uni Selector doesn't recognize the changed values.
Below is how i am making the updates that are propagating to the database.
newAuthorRefference = guid;guid;guid;...

   article.SetValue("Author", newAuthorRefference);
   article.Update(); 

Correct Answer

Brenden Kehren answered on October 13, 2017 23:29

If you're using check in/out then your code should work. If you're simply using workflow, then an article.Publish() will do what you need.

0 votesVote for this answer Unmark Correct answer

Recent Answers


Brenden Kehren answered on October 11, 2017 00:47

The class defnintion of that field in the background is probably referencing another unigue identifier which is why you are seeing those results. I'd suggest reviewing the class defintion of both page types and compare that field in particular. You can find the definition in the cms_class table under the ClassFormDefinition field

0 votesVote for this answer Mark as a Correct answer

paul krysiak answered on October 12, 2017 19:35

Brendon
Thanks! , i check the tables you referenced and i am looking at the right field. I found a sql error, i'll check the relationships that it is looking for and let you know what i find.

0 votesVote for this answer Mark as a Correct answer

paul krysiak answered on October 13, 2017 23:00

Brendon
I found what the issue is (probably). The table has the correct information. There is a workflow enabled that pulls the last version. The form on the page type is looking a the version history not the table data. I thought something like this would happen and i was working through the api to avoid this but apparently the api doesn't update the version history automatically with the update command. The process is running through this pipline.
https://docs.kentico.com/k9/integrating-3rd-party-systems/using-the-kentico-api-externally
i didn't know about using this practice.
https://docs.kentico.com/api9/content-management/page-workflow-and-versioning

Does this sound like the right direction?

if(!article.IsCheckedOut)
{
    // Checks out the page
    article.CheckOut();
}
article.SetValue("Author", newAuthorRefference);
article.Update();
article.checkin();
0 votesVote for this answer Mark as a Correct answer

paul krysiak answered on October 13, 2017 23:33

The cmsdesk has " create new version " and there is a workflow attached (submit, approve, publish). Will the publish() save that new version?

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on October 13, 2017 23:34

Publish will create the new version when it is published.

0 votesVote for this answer Mark as a Correct answer

paul krysiak answered on October 13, 2017 23:46

Perfect!
I'll run my test and let you know.
Thanks again!

0 votesVote for this answer Mark as a Correct answer

paul krysiak answered on October 16, 2017 15:22 (last edited on October 16, 2017 15:48)

I found that the system doesn't have workflow.
When i call article.publish(); i get this error.
Does this error message look familiar when publishing content in the api?

Task type 'DICTIONARYCOMMAND' is not supported. The task needs to be registered with WebFarmHelper.RegisterTask method.
0 votesVote for this answer Mark as a Correct answer

paul krysiak answered on October 23, 2017 21:56

Brandon
I finally figured out what the issue was.
It was two things;
First was the workflow was not applied evenly across the entire page set,
Second was that to run this operation in a remote application i would need to move the function into a WebFarmHelper.RegisterTask.

I moved the code into the cms to avoid the Register task bit and after applying the workflow evenly across all the pages it updated correctly.
Thanks for your help.

0 votesVote for this answer Mark as a Correct answer

paul krysiak answered on November 6, 2017 18:34

Brenden
I have implemented the above code and i am not getting consistent results. I kno whte changes were made but for some reason this is happening . I'm not getting any errors in the logs.

 if (!cbTest.Checked)
        {
            WorkflowManager workflowManager = WorkflowManager.GetInstance(_naisTree);

            WorkflowInfo workflow = workflowManager.GetNodeWorkflow(article);
            if (workflow != null){
            if (!article.IsCheckedOut)
                try{
                article.CheckOut();
                }catch(Exception ex){
                    EventLogProvider.LogEvent(EventType.ERROR, "Author Checkout ", "SWP", "ca't checkout " + ex.Message);
                }
            }

            article.SetValue("Author", newAuthorRefference);
            article.Update();
            if (workflow != null){
                try{
                article.CheckIn();
            }catch(Exception ex){
                    EventLogProvider.LogEvent(EventType.ERROR, "Author Checkin ", "SWP", "ca't checkin " + ex.Message);
                }
        }
            if (workflow != null){
                try{
                article.Publish();

                //article.Publish("updated via api");
                }catch(Exception ex){
                    EventLogProvider.LogEvent(EventType.ERROR, "Author publish ", "SWP", "ca't publish " + ex.Message);
                }
            }


        }

Image Text Any ideas?

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.