I have an on execute method that has variable "item". I need to pass that variable to my other method "IsStatusChangeValid"
Below is what I currently have, but so far its not working. I looked at some related questions on stack overflow such as Accessing Variables From Another Method and looked at some parameter passing tutorials/examples online such as Parameter Passing in C# but I have been unable to apply the information properly.
protected override CommandResult OnExecute()
{
var item = ItemViews.ItemGet(itemId);
if (IsStatusChangeValid())
{
...
}
else
{
...
}
}
public bool IsStatusChangeValid(item)
{
// ONLY IF SET EXISTS
if (item.ItemSets.Count > 0)
{
// CHECK IF ITEM STATUS IS CHANGED TO "CLOSED-VOIDED"
if (newDescription.Equals("Closed-Voided"))
{
// IF THERE ARE NON-VOIDED SETS, DO NOT ALLOW THE STATUS CHANGE
if (item.ItemSets.Any(p => p.SetStatusID != SetStatusIDConstants.Voided))
{
return false;
}
}
}
return true;
}
OnExecutemethod? What did you try that didn't work (and why didn't it work)?if (IsStatusChangeValid) {do work} else {stop and post warning}I've triedIsStatusChangeValid(item)andIsStatusChangeValid(ItemViews item)andIsStatusChangeValid(Item item)The first one throws an error under item. The second two throw errors from within theIsStatusChangeValidmethod.IsStatusChangeValid(item)is correct, what error did you get