SubscriptionSchedulerCmd not running without a registered userId - HCL Commerce / IBM WCS - websphere-commerce

I am implementing the OOB Recurring Order feature in our store.
I am setting up the SubscriptionSchedulerCmd as explained in this wiki https://help.hcltechsw.com/commerce/9.0.0/admin/tasks/tin_settingupscheduler.html?hl=setting%2Cup%2Cscheduler%2Cprocess%2Csubscriptions%2Crecurring%2Corders
But the scheduler is not running as expected. I see the following error from the logs
CommerceSrvr A AccManager performForUserAuthorizationCheck(AccCommand) The run-as-identity must be of registered type.
ExtendedInfo I CWXFR9010I: Extended information : [context=com.ibm.commerce.context.base.BaseContext : [bInitialize = false][bRecalibrate = true][inCallerId = -1000][inRunAsId = 291003][inStoreId = 10151][istrChannelId = null][bDirty = true][bRequestStarted = true][iOriginalSerializedString = 0&-1000&-1000&null][iToken = 21450482:true:true:0]] [queryString=] [schedulerName=SubscriptionSchedulerCmd]
But it runs fine for the recurring orders of one particular user if I give that userIdin the associated user field in the schduler configurator. What am I missing here ?

SubscriptionSchedulerCmd only runs for USERS of REGISTERTYPE = "R". So if a USER is both R and S the precedence is for S for the command will not run and will not create child orders.

Related

How to create, delete and update Test Steps listed in VSTS Test Cases

We are working on building an approach that automatically update test suite's execution metrics onto the VSTS server. After going through the REST API document for VSTS, we were able to do the following using those automated APIs
Create a Test RUN with desired list of existing test cases
Update the Test RESULTS (outcome and status) for the above created Test RUN
Now it is possible to update whether the Test Case is Pass, Fail or any other available outcomes. But we are looking for an automated approach with which we can update the status of each Test Step inside each Test Case to Pass, Fail or any other available outcomes.
Hope I have explained our pain area in more understandable way.
Please reply your suggestions.
Thanks in advance.
Test Steps listed in VSTS Test Cases still belongs to test result.
If you get a test result with parameter `detailsToInclude=Iterations', you will see there is "actionResults" to determine test steps outcome:
Get https://xxx.visualstudio.com/TestCase/_apis/test/runs/xx/results/xx?api-version=3.0-preview&detailsToInclude=Iterations
But I've tried update "actionResults" with REST api Update test results for a test run, and found it doesn't support update "actionResults". Your requirement can not be achieved with rest api.
Instead of REST api, you can use the client api as this case mentioned: How to add/update individual result to each test step in testcase of VSTS/TFS programatically
Simple sample:
int testpointid = 176;
var u = new Uri("https://[account].visualstudio.com");
VssCredentials c = new VssCredentials(new Microsoft.VisualStudio.Services.Common.VssBasicCredential(string.Empty, "[pat]"));
TfsTeamProjectCollection _tfs = new TfsTeamProjectCollection(u, c);
ITestManagementService test_service = (ITestManagementService)_tfs.GetService(typeof(ITestManagementService));
ITestManagementTeamProject _testproject = test_service.GetTeamProject("scrum2015");
ITestPlan _plan = _testproject.TestPlans.Find(115);
ITestRun testRun = _plan.CreateTestRun(false);
testRun.Title = "apiTest";
ITestPoint point = _plan.FindTestPoint(testpointid);
testRun.AddTestPoint(point, test_service.AuthorizedIdentity);
testRun.Save();
testRun.Refresh();
ITestCaseResultCollection results = testRun.QueryResults();
ITestIterationResult iterationResult;
foreach (ITestCaseResult result in results)
{
iterationResult = result.CreateIteration(1);
foreach (Microsoft.TeamFoundation.TestManagement.Client.ITestStep testStep in result.GetTestCase().Actions)
{
ITestStepResult stepResult = iterationResult.CreateStepResult(testStep.Id);
stepResult.Outcome = Microsoft.TeamFoundation.TestManagement.Client.TestOutcome.Passed; //you can assign different states here
iterationResult.Actions.Add(stepResult);
}
iterationResult.Outcome = Microsoft.TeamFoundation.TestManagement.Client.TestOutcome.Passed;
result.Iterations.Add(iterationResult);
result.Outcome = Microsoft.TeamFoundation.TestManagement.Client.TestOutcome.Passed;
result.State = TestResultState.Completed;
result.Save(true);
}
testRun.State = Microsoft.TeamFoundation.TestManagement.Client.TestRunState.Completed;
results.Save(true);

Azure AD Graph API ApproleAssignment does not allow zero GUID

I am getting an error when trying to add AppRoleAssignment for a user:
{"odata.error":{"code":"Request_BadRequest","message":{"lang":"en","value":"One or more properties are invalid."},"date":"2017-10-21T14:49:42","requestId":"3aacf13e-5620-40da-8fd0-fb2d4130f171","values":null}}
When i use an actual ApproleId, everything works fine. However, when i set
AppRoleAssignment.Id = new Guid(); i get the above error;
This does not make sense, because the documentation says that this is allowed
by setting zero GUID and the same has been stressed in other posts on SO.
What am i missing here?
Full code:
AppRoleAssignment appRoleAssignment = new AppRoleAssignment()
{
Id = new Guid(),
ResourceId = Guid.Parse(servicePrincipal.ObjectId),
PrincipalId = Guid.Parse(user.ObjectId),
PrincipalType = "User"
};
user.AppRoleAssignments.Add(appRoleAssignment);
await user.UpdateAsync();
Based on my experience, there are two scenarios we may get this issue.
First, if there is customize roles in the service principal you want to assign the default role.
Second, if we have already assigned the default role to that person before.
Please check whether you are in one of these two scenarios and let me know if you still have the problem about this issue.

CRM 2011 - CloseIncidentRequest - Throws Exception when registered on Create Case Post Event

I am trying to get a plugin registered on the case ("incident") create post synchronous event to successfully call the CloseIncidentRequest. I have the CloseIncidentRequest working successfully on the case update post event but on the create I keep getting the "Need to start a transaction before commit" exception.
Does anyone know if this is a known issue, or has anyone got this running on the case create post event? I have seen posts around changing from synchronous to asynch - and if I change the plugin to run asynch, that does work - but ideally I want this to run this synchronously, so that the user can see that the case has been resolved when pressing save.
private const int IncidentResolutionStatus_Closed = 2;
private const int IncidentStatusCode_ProblemSolved = 5;
Entity resolution = new Entity("incidentresolution");
resolution["subject"] = "Case Resolved";
resolution["incidentid"] = new EntityReference("incident", IncidentId);
resolution["timespent"] = timespent;
resolution["statuscode"] = new OptionSetValue(IncidentResolutionStatus_Closed);
CloseIncidentRequest closeincidentRequest = new CloseIncidentRequest()
{
IncidentResolution = resolution,
Status = new OptionSetValue((int)IncidentStatusCode_ProblemSolved)
};
service.Execute(closeincidentRequest);
Try resolving the case manually (through the CRM interface) and you probably will get the same error (like me).
If so it's not related to your plugin code (or SDK), but on some missing information when you created the case.
Check if on the case you are trying to resolve there is no missing required field. In my case the error was that the Client name was null (there was a client record but its name was null) and it was causing the error.

Trying to change owner of account on CRM 4.0 using a plugin

I am creating a plugin for Microsoft Dynamics CRM 4 that will change the owner of the account entity according to the value of another lookup field. Now I have managed to get the GUID of the user that will be acting as the 'Owner' of the account. So far so good.
The problem arises when I try to change the owner. I am trying to use AssignRequest but it is not working. When I try to execute the request I get a SoapException on the C# Debugger, and the webservice outputs a dialog stating:
"The requested record was not found or you do not have sufficient permissions to view it"
Below is the code I am using:
TargetOwnedAccount target = new TargetOwnedAccount();
SecurityPrincipal assignee = new SecurityPrincipal();
assignee.Type = SecurityPrincipalType.User;
assignee.PrincipalId = context.InitiatingUserId;
target.EntityId = ownerGuid; //this is the GUID I am retrieving from the other lookup field
AssignRequest assign = new AssignRequest();
assign.Assignee = assignee;
assign.Target = target;
AssignResponse res = (AssignResponse)crmService.Execute(assign); //this is where i get the exception
I hope I haven't missed anything.
Any help would be much appreciated :)
Thanks
Ok i managed to solve this finally. It had been staring directly at my face :P
I was entering the wrong ID's at the wrong place. I needed to set the 'assignee.PrincipalId' to the 'ownerGuid' and then set the 'target.EntityId' to the current account id. The new code is as follows:
TargetOwnedAccount target = new TargetOwnedAccount();
SecurityPrincipal assignee = new SecurityPrincipal();
assignee.Type = SecurityPrincipalType.User;
assignee.PrincipalId = ownerGuid; //this is the GUID I am retrieving from the other lookup field
target.EntityId = ((Key)entity.Properties["accountid"]).Value;
AssignRequest assign = new AssignRequest();
assign.Assignee = assignee;
assign.Target = target;
AssignResponse res = (AssignResponse)crmService.Execute(assign);
Cant believe i spent 8 hours yesterday looking at it and then today I realised immediately :P

Creating a trigger on aspnet_membership makes login fail

I'm doing some maintance on an older web application where we have 2 DB's. One for the WWW frontend (DotNetNuke) and another for the admin backend. Both of the applications use aspnet_membership for users, and we want to sync logins between the app's. I thought we'd do this with a trigger, but logins starts failing when I add the trigger.
USE dnnTicket
GO
CREATE TRIGGER update_membership ON dbo.aspnet_Membership
AFTER UPDATE
AS
SET NOCOUNT ON
IF (trigger_nestlevel() > 1) RETURN --Make sure a similar trigger on the other db don't cause infinite loops.
UPDATE ticket4you.dbo.aspnet_Membership SET
[Password] = INSERTED.[Password],
PasswordFormat = INSERTED.PasswordFormat,
PasswordSalt = INSERTED.PasswordSalt,
MobilePIN = INSERTED.MobilePIN,
Email = INSERTED.Email,
LoweredEmail = INSERTED.LoweredEmail,
PasswordQuestion = INSERTED.PasswordQuestion,
PasswordAnswer = INSERTED.PasswordAnswer ,
IsApproved = INSERTED.IsApproved ,
IsLockedOut = INSERTED.IsLockedOut ,
CreateDate = INSERTED.CreateDate ,
LastLoginDate = INSERTED.LastLoginDate ,
LastPasswordChangedDate = INSERTED.LastPasswordChangedDate,
LastLockoutDate = INSERTED.LastLockoutDate ,
FailedPasswordAttemptCount = INSERTED.FailedPasswordAttemptCount ,
FailedPasswordAttemptWindowStart = INSERTED.FailedPasswordAttemptWindowStart ,
FailedPasswordAnswerAttemptCount = INSERTED.FailedPasswordAnswerAttemptCount ,
FailedPasswordAnswerAttemptWindowStart = INSERTED.FailedPasswordAnswerAttemptWindowStart
FROM INSERTED
WHERE ticket4you.[dbo].aspnet_Membership.UserId = INSERTED.userID
SET NOCOUNT OFF
GO
With this trigger in the DB logins using the dnnTicket db fails.
I traced the SQL server activity as best I could and found a very strange difference in the trace from when the query is run in the web server to when I manualy run the same query from SMMS.
At a glance the trigger looks ok.
I would start by checking that both applications have the same configuration for the membership provider, and the same machine keys.
Then I would look for any error message that may be getting recorded. The DNN event viewer, (and log4net log file in 6.0) are good sources. If there is nothing I would use sql profiler to look for any messages related to trigger/login process.
Also can you describe the failure in more detail? Does the trigger prevent logging in to both systems, or can you log into system A, but then not system B, or you can only ever access one system?