How to move multiple rows to another sheet via API
I have code in C# that moves a row from one sheet to another, but I can only get it to work when I hard code the row id in the CopyOrMoveRowDirective line. What is the syntax for passing a row id into the statement? I have tried rowm.ID in place of 80233296095108, but i get a syntax error. Here is a simplified version of the code, but need to pass in the current rowid as I loop through.
foreach (Row rowm in sheet.Rows)
{
{
CopyOrMoveRowDestination destination = new CopyOrMoveRowDestination { SheetId = 336102784558980 };
CopyOrMoveRowDirective directive = new CopyOrMoveRowDirective { RowIds = new long[] { 80233296095108 }, To = destination };
CopyOrMoveRowResult results = smartsheet.SheetResources.RowResources.MoveRowsToAnotherSheet(3267158118557572, directive, null, null);
}
}
Thanks
Mike
Comments
-
Hi Michael,
If you haven’t already, I would recommend that you also check Stack Overflow.
https://stackoverflow.com/questions/tagged/smartsheet-api
Have a fantastic week!
Best,
Andrée Starå
Workflow Consultant @ Get Done Consulting
SMARTSHEET EXPERT CONSULTANT & PARTNER
Andrée Starå | Workflow Consultant / CEO @ WORK BOLD
W: www.workbold.com | E: [email protected] | P: +46 (0) - 72 - 510 99 35
Feel free to contact me about help with Smartsheet, integrations, general workflow advice, or something else entirely.
0 -
Hi Mike,
It looks like you may have asked this question on StackOverflow here. That post goes over a solution the original poster found declaring a new variable to store the row id value and use that in the directive.
0 -
Thanks everyone. The key, as stated above, is that I needed to pass the .value in, which i originally was not doing.
0 -
Happy to help!
Best,
Andrée
SMARTSHEET EXPERT CONSULTANT & PARTNER
Andrée Starå | Workflow Consultant / CEO @ WORK BOLD
W: www.workbold.com | E: [email protected] | P: +46 (0) - 72 - 510 99 35
Feel free to contact me about help with Smartsheet, integrations, general workflow advice, or something else entirely.
0