CRM 2015 update - plugin error - 'Changing security attributes is not allowed in stage 20 plugins' - dynamics-crm-2013

When i tried to create another type of an entity record in the post update plugin stage I have gotten "Changing security attributes is not allowed in stage 20 plugins" error.
Its working fine in Dynamics CRM 2013 SP1 CRM.
After update CRM 2013 to CRM 2015 i got this error

Remove logic from pre create and move it to post create of the other entity. then it will working fine

Remove unwanted attribute from plugin images.only select attribute that you need in the plugin.You can set it when you registering plugin(don't tick all attributes check box).remove security related attribute(owner, modified by, created on)

Some of you might get this error in the plugin steps when an organization is being migrated to CRM 2015.
Cause:
You change the ownership of the record in the record Pre-creation
Resolution:
Most solutions out there say about change the plugin to Post-operation stage, but this don't make sense for some of the actions/checks that your plugin could do.
So, what you could do is to check the pipeline stage before you run the assignment operation.
https://msdn.microsoft.com/en-us/library/gg327941.aspx#bkmk_PipelineStages
Sample code:
//Runs on the Pre-Validation step, when a Contact is created
if (context.Stage == 10)
{
if (!targetEntity.Attributes.Contains("parentcustomerid"))
{
throw new InvalidPluginExecutionException("Message to show....");
}
try
{
var accountOwner = (from a in orgServiceContext.AccountSet
where a.Id == targetContact.ParentCustomerId.Id
select a).Single();
targetEntity.Attributes["ownerid"] = new EntityReference("team", accountOwner.OwnerId.Id);
targetEntity.Attributes["owningbusinessunit"] = new EntityReference("businessunit", accountOwner.OwningBusinessUnit.Id);
}
catch
{
throw new InvalidPluginExecutionException("Message to show...");
}
}
Found another solution: Move your plugin step to Pre-Validation.

Related

Polarion API: How to update multiple work items in the same action

I created a script which updates work items in a polarion document. However, right now each workitem update is a single save. But my script updates all work items in the document, which results in a large number of save actions in the api and thus a large set of clutter in the history.
If you edit a polarion document yourself, it will update all workitems.
Is it possible to do this same thing with the polarion API?
I tried
Using the tracker service to update work items. This only allows a single work item to be updated.
Using the web development tools to try and get information from the API. This seems to use a UniversalService for which no documentation is available at the API site https://almdemo.polarion.com/polarion/sdk/index.html
Update 1:
I am using the python polarion package to update the workitems.Python polarion Based on the answer by #boaz I tried the following code:
project = client.getProject(project_name)
doc = project.getDocument(document_location)
workitems = doc.getWorkitems()
session_service = client.getService("Session")
tracker_service = client.getService("Tracker")
session_service.beginTransaction()
for workitem in workitems:
workitem.description = workitem._polarion.TextType(
content=str(datetime.datetime.now()), type='text/html', contentLossy=False)
update_list = {
"uri": workitem.uri,
"description": workitem.description
}
tracker_service.updateWorkItem(update_list)
session_service.endTransaction(False)
The login step that #boaz indicated is done in the backend (See: https://github.com/jesper-raemaekers/python-polarion/blob/3e61527cf0f1f3c8614a30289a0a3409d2d8712d/polarion/polarion.py#L103)
However, this gives the following Java exception:
java.lang.RuntimeException: java.lang.NullPointerException
Update 2
There seems to be an issue with the session. If I call the following code:
session_service.logIn(user, password)
print(session_service.hasSubject())
it prints False.
The same thing happens when using the transaction:
session_service.beginTransaction()
print(session_service.transactionExists())
also prints False
Try wrapping your changes in a SessionWebService transaction, see JavaDoc:
sessionService = factory.getSessionService();
sessionService.logIn(prop.getProperty("user"),
prop.getProperty("passwd"));
sessionService.beginTransaction();
// ...
// your changes
// ...
sessionService.endTransaction(false);
sessionService.endSession();
As shown in the example in Polarion/polarion/SDK/examples/com.polarion.example.importer.
This will commit all your changes in one single SVN commit.

Core Data + CloudKit Migration: Cannot create or modify field [...] in record [...] in production schema

I use NSPersistentCloudKitContainer to sync Core Data with Cloud Kit. To prepare for a new migration, I have created a new model version of the xcdatamodel and marked it as "current". I created a new entity and added a relationship from another entity. Nothing spectacular and suitable for a lightweight migration I thought.
Let's name this new entity: EntityNew
This is my code to initialize the NSPersistentCloudKitContainer:
lazy var persistentContainer: NSPersistentContainer = {
let container = NSPersistentCloudKitContainer(name: "MyContainerName")
container.loadPersistentStores(completionHandler: { _, error in
guard let error = error as NSError? else { return }
fatalError("###\(#function): Failed to load persistent stores:\(error)")
})
container.viewContext.automaticallyMergesChangesFromParent = true
return container
}()
shouldMigrateStoreAutomatically and shouldInferMappingModelAutomatically are set to true by default.
Everything worked fine locally. No errors occurred during the migration.
The problems started when I created a new instance of EntityNew:
let newItem = EntityNew(context: context)
newItem = "..."
saveContext()
newItem was created locally without any problems, but the iCloud Sync stopped working from this moment. The following error appeared in the console:
"<CKRecordID: 0x283fb1460; recordName=2E2209A1-F9F6-4DF2-960D-2C31F764ED05, zoneID=com.apple.coredata.cloudkit.zone:__defaultOwner__>" = "<CKError 0x2830a5950: \"Batch Request Failed\" (22/2024); server message = \"Atomic failure\"; uuid = ADA626F4-160E-49FE-A0BD-2198E5FBD09A; container ID = \"iCloud.[MyContainerID]\">"
"<CKRecordID: 0x283fb1a00; recordName=3145C837-D80D-47E0-B944-DBC6576A9B0A, zoneID=com.apple.coredata.cloudkit.zone:__defaultOwner__>" = "<CKError 0x2830a4000: \"Invalid Arguments\" (12/2006); server message = \"Cannot create or modify field 'CD_[Fieldname in EntityNew]' in record 'CD_[OtherEntityName]' in production schema\"; uuid = ADA626F4-160E-49FE-A0BD-2198E5FBD09A; container ID = \"iCloud.[ContainerID]\">";
"Cannot create or modify field 'CD_[Fieldname in EntityNew]' in record 'CD_[OtherEntityName]' in production schema"
Cloud Kit tries to modify the field CD_[Fieldname in EntityNew] (which is correct) on the record CD_[OtherEntityName], which is not the entity I created above! So Core Data tries to modify the wrong entity! This behavior does not happen for all fields (approx. 5 out of 10). I checked the local sqlite file of my iPhone but the local tables seems correct. The phenomenon can be observed in both, the Development and the Production icloud-container-environment. If I start with an empty database (which already contains the new entity, so no migration is necessary) the synchronization works.
What did I miss? Any ideas?
Thank you!

Can't find method error using WL.Server.setActiveUser()

I'm trying to determine the best approach for executing business logic in a Push adapter. I've run the example PushAdapter (Module_07_04_nativeAPIForiOSPush) successfully from my local environment, but, adding WL.Server.setActiveUser() throws an error.
I'm running the demo PushAdapter adapter locally in Worklight Studio (6.0.0.201309171829), added as the first line in the adapter:
WL.Server.setActiveUser("PushAppRealm",userId);
...
Deployed the adapter change, run with same params and get this error in the Worklight console:
Can't find method com.worklight.integration.js.JavaScriptIntegrationLibraryImplementation.setUserIdentity(string,string). (/integration.js#36)
FWLSE0101E: Caused by: [project Module_07_04_nativeAPIForiOSPush]null
The adapter runs without any problems without this line. I'm trying to set the active user because I want to get the user's preferences next to determine business logic on whether to create the notification. Is there another approach?
I've also run this in a new workspace (after I applied the Fix Pack 1 to WL Studio 6), but, same result.
Questions are 1) why getting this error?, and 2) is this a valid approach?
Thanks.
var userIdentity = {
userId: "userid",
displayName: "userid",
attributes: {
foo: "bar"
}
};
WL.Server.setActiveUser("PushAppRealm", userIdentity);
This should work. However for this sample you should not be explicitly setting the user identity.The method WL.Server.setActiveUser() is used to set the user identity in case of adapter based authentication.This sample uses form based authentication.

JIRA, get a parent issue via SOAP api

I need to obtain a parent issue of given issue via SOAP API, or even using database. It seems to be very basic objective, however I didn't find any useful information in internet. Besides, I didn't find any fields in jira's db tables (jiraissue) to set the parent issue of an issue.
Additional info: Jira 5.1, c# .Net
As far as I know there is no way to do this using the SOAP directly.
One possible solution would be using the Jira Scripting Suite. You can create a post-function that will run after the Open status that will copy the parent to a custom field using getParentObject. Then you could use the SOAP function getCustomFields to get the parent.
Another solution via REST API:
Issue issue = getRestClient().getIssueClient().getIssue(task.getKey(), new NullProgressMonitor());
Field issueParent = issue.getField("parent");
if (issueParent  !=null){
    JSONObject jsonParent = (JSONObject)issueParent.getValue();
    BasicIssue partsedIssue = null;
    try {
        partsedIssue = new BasicIssueJsonParser().parse(jsonParent);
    } catch (JSONException e1) {
        e1.printStackTrace();
    }
    System.out.println("parent key: "+partsedIssue.getKey());
}

Querying into alternate workspaces with Rally C# API

I'm making a bunch of Rally API calls using the C# Rally Rest API Wrapper, with great success... except when I'm trying to query into a non-default workspace. For example, take this code:
public Project GetProject(string objectID)
{
Request request = new Request("Project");
// request.Workspace = "2354109555"; //"CTO:SST";
request.Query = new Query("ObjectID", Query.Operator.Equals, objectID);
QueryResult q = _restApi.Query(request);
foreach (var result in q.Results)
{
return CreateProjectFromResult(result);
}
return null;
}
If objectID is in the default workspace, the project is found. If it is not, it is not found. I've tried setting the Workspace property to the workspace object id, the workspace name, not setting it.. to no avail. I've also gone into Rally, switched my default workspace, and verified the switch in which projects are successfully obtained.
I've also triple checked the objectIDs for the projects and workspaces.
I'm officially stumped. Does anyone have the magic answer or something else I can try?
Much appreciated,
Orlando
I think you're 99 pct of the way there. When you specify a workspace attribute on your Request object, it needs to be in the form of a ref, i.e.:
request.Workspace = "/workspace/2354109555"; //"CTO:SST";
Your code should pull from that Workspace once you make that modification.