private static void CopyRowToCreatedSheet(SmartsheetClient smartsheet, long sheetId, long rowId) { long tempSheetId = smartsheet.SheetResources.CreateSheet(new Sheet.CreateSheetBuilder("tempSheet", new Column[] { new Column.CreateSheetColumnBuilder("col1", true, ColumnType.TEXT_NUMBER).Build() }).Build()).Id.Value; CopyOrMoveRowDestination destination = new CopyOrMoveRowDestination { SheetId = tempSheetId }; CopyOrMoveRowDirective directive = new CopyOrMoveRowDirective { RowIds = new long[] { rowId }, To = destination }; CopyOrMoveRowResult result = smartsheet.SheetResources.RowResources.CopyRowsToAnotherSheet(sheetId, directive, new CopyRowInclusion[] { CopyRowInclusion.CHILDREN }, false); }
/// <summary> /// <para>Moves Row(s) from the Sheet specified in the URL to (the bottom of) another sheet.</para> /// <para>It mirrors To the following Smartsheet REST API method: POST /sheets/{sheetId}/rows/copy</para> /// <remarks><para>Up to 5,000 row IDs can be specified in the request, /// but if the total number of rows in the destination sheet after the copy exceeds the Smartsheet row limit, /// an error response will be returned.</para> /// <para>Any child rows of the rows specified in the request will also be moved. /// Parent-child relationships amongst rows will be preserved within the destination sheet.</para></remarks> /// </summary> /// <param name="sheetId"> the sheet Id </param> /// <param name="ignoreRowsNotFound"> ignoreRowsNotFound </param> /// <param name="directive"> directive </param> /// <param name="include">the elements to include.</param> /// <returns> CopyOrMoveRowResult object </returns> /// <exception cref="System.InvalidOperationException"> if any argument is null or empty string </exception> /// <exception cref="InvalidRequestException"> if there is any problem with the REST API request </exception> /// <exception cref="AuthorizationException"> if there is any problem with the REST API authorization (access token) </exception> /// <exception cref="ResourceNotFoundException"> if the resource cannot be found </exception> /// <exception cref="ServiceUnavailableException"> if the REST API service is not available (possibly due To rate limiting) </exception> /// <exception cref="SmartsheetException"> if there is any other error during the operation </exception> public virtual CopyOrMoveRowResult MoveRowsToAnotherSheet(long sheetId, CopyOrMoveRowDirective directive, IEnumerable<MoveRowInclusion> include, bool? ignoreRowsNotFound) { Utility.Utility.ThrowIfNull(directive); IDictionary<string, string> parameters = new Dictionary<string, string>(); if (include != null) { parameters.Add("include", QueryUtil.GenerateCommaSeparatedList(include)); } if (ignoreRowsNotFound.HasValue) { parameters.Add("ignoreRowsNotFound", ignoreRowsNotFound.ToString().ToLower()); } return this.CreateResource<CopyOrMoveRowResult, CopyOrMoveRowDirective>(QueryUtil.GenerateUrl("sheets/" + sheetId + "/rows/move", parameters), directive); }