Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create new related workitem. #278

Open
rbhole opened this issue Mar 29, 2023 · 3 comments
Open

Create new related workitem. #278

rbhole opened this issue Mar 29, 2023 · 3 comments

Comments

@rbhole
Copy link

rbhole commented Mar 29, 2023

I want to create new related item NOT child item. My code as below,

if (parent.WorkItemType == "Risk") {
	if (parent.State == "Impacted")
	{
		var newChild = store.NewWorkItem("Issue");
		newChild.Title = "Issue " + parent.Title;
		newChild.State = "Identify";
		newChild.Description = "Issue created due to " + parent.Title + " Impacted";
		parent.Relations.Add(newChild);
		logger.WriteInfo("Issue added"); 
	}
}

I got error as below,

Errors in the rule file D:\Autocalculation\createWorkItem_Demo.rule:
(14,24): error CS1503: Argument 1: cannot convert from 'aggregator.Engine.WorkItemWrapper' to 'aggregator.Engine.WorkItemRelationWrapper'
[2023-03-29 16:27:08Z] Rule file is invalid
[2023-03-29 16:27:08Z] update.rule Failed!
[2023-03-29 16:27:08Z] Exiting with code 1

I gone through /scr from library... but unable to find out solution.

@giuliov
Copy link
Member

giuliov commented Mar 31, 2023

Have you tried

parent.AddRelatedLink(newChild, "Impacted by Risk");

@rbhole
Copy link
Author

rbhole commented Apr 3, 2023

Thank you @giuliov

@Gr4nOuvert
Copy link

Gr4nOuvert commented Dec 1, 2023

Hello @giuliov,
I have tried your example but I dont think that its working as supposed:
Have you got a clue?

My code:
var childItem = store.GetWorkItem(child.Id); self.AddRelatedLink(childItem, "Aggregator created link");

but i get following error message:
Rule \u0027test\u0027 failed: (44,22): error CS1061: \u0027WorkItemWrapper\u0027 does not contain a definition for \u0027AddRelatedLink\u0027 and no accessible extension method \u0027AddRelatedLink\u0027 accepting a first argument of type \u0027WorkItemWrapper\u0027 could be found (are you missing a using directive or an assembly reference?)"

Update:
i found the error.
You have to use self.Relations.AddRelatedLink(..)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants