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:andree@workbold.com | P: +46 (0) - 72 - 510 99 35
Feel free to contact me for help with Smartsheet, integrations, general workflow advice, or anything else.
-
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.
-
Thanks everyone. The key, as stated above, is that I needed to pass the .value in, which i originally was not doing.
-
Happy to help!
Best,
Andrée
SMARTSHEET EXPERT CONSULTANT & PARTNER
Andrée Starå | Workflow Consultant / CEO @ WORK BOLD
W: www.workbold.com | E:andree@workbold.com | P: +46 (0) - 72 - 510 99 35
Feel free to contact me for help with Smartsheet, integrations, general workflow advice, or anything else.
Categories
- All Categories
- 14 Welcome to the Community
- Smartsheet Customer Resources
- 64.1K Get Help
- 414 Global Discussions
- 221 Industry Talk
- 461 Announcements
- 4.8K Ideas & Feature Requests
- 143 Brandfolder
- 141 Just for fun
- 58 Community Job Board
- 462 Show & Tell
- 32 Member Spotlight
- 1 SmartStories
- 299 Events
- 38 Webinars
- 7.3K Forum Archives