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
- 63.5K Get Help
- 402 Global Discussions
- 213 Industry Talk
- 450 Announcements
- 4.7K Ideas & Feature Requests
- 141 Brandfolder
- 135 Just for fun
- 56 Community Job Board
- 454 Show & Tell
- 31 Member Spotlight
- 1 SmartStories
- 296 Events
- 36 Webinars
- 7.3K Forum Archives