SharePoint 2010 Approval Work Flow Form – Link to Attachment

I have created a custom approval workflow that works as expected. However I am trying to add a link on the approval form to any attachments that were assigned during the creation of the list item.

The steps that I have taken so far: Added a workflow variable Set the workflow variable to the value of the current item attachments Added a Task Form Field of type string Set the Task Form Field value to the Value of the Work Flow variable in the Before Task is Assigned Step

There are no errors within the workflow, but when the workflow is initiated (automatic or manual), no task notifications are sent. If I removed the Set Task Form Field value, the workflow will start sending notifications again. I’m assuming it has something to do with how I am trying to build the link to the attachment within the form.

How can I get the Description textarea field to use the Visual Editor for Attachment Posts

I saw this post involving tags. But I can’t figure out which

/**  * Display advanced TinyMCE editor in taxonomy page  */ function wpse_7156_enqueue_category() { global $  pagenow, $  current_screen;  if( $  pagenow == 'edit-tags.php' ) {     require_once(ABSPATH . 'wp-admin/includes/post.php');     require_once(ABSPATH . 'wp-admin/includes/template.php');      wp_tiny_mce( false, array( 'editor_selector' => 'description', 'elements' => 'description', 'mode' => 'exact' ));    }  }  add_action( 'init', 'wpse_7156_enqueue_category' ); 

This seems to have been rendered redundant in newer versions of WordPress. But I wonder if it could be used for attachments? I just need to know the include for that attachment editing page?

read content of list item attachment in SPD workflow and convert to base64 string

I need to write a workflow that reads the content of attachment of a list item, convert it to base64 encoded string and then invoke a custom REST service.

I know I can access /_api/web/lists/getbytitle('MyList')/items(" + id + ")/AttachmentFiles and get the server relative URL of the attachment from result.

But I’m not sure how to get the contents of that file and convert it to base64 string.


I’ve found the following REST API that allows me to read the content of the attachment:

/_api/web/getfilebyserverrelativeurl('server relative URL of attachment from earlier call')/$  value 

Now the question remains that how to get this content in base64 format?

Create an item attachment from a template based on multiple item

To further explain the question better I’ll explain what I want to acomplish. So we have a person that requests parts through sharepoint by adding a new item with all the details and an automatic request form is attached to this item using Flows. Then another person takes this item and orders the said parts. Now the problem is a lot of times multiple parts need to be requested under the same order and the final request form has to have all of the parts in it instead of having a single sheet generated for each part. My question is, is there a way to create multiple items and have flows combine and generate a single attachment for all of the created items? or have sub items for a single request?

Upload file content from API to sharepoint list item attachment

So I’m trying to upload a file, or multiple files, to a sharepoint as attachments to a list item. I have the code to upload the actual files but they’re corrupt/unopenable when trying to access them in sharepoint.

I receive these files from an outside API in the form of:

{     "File": {         "contentType": ~~~~         "fileContent": ~~~~         "name": ~~~~.docx/.pdf     } } 

I currently am trying to upload it like this:

spClient.DefaultRequestHeaders.Add("Accept", "application/json;odata=verbose");  foreach (var file in data["files"]) {     var requestString = $  "{siteUrl}/lists('{listID}')/items('{siteResponseObject["id"]}')/AttachmentFiles/add(FileName='{file["File"]["name"]}')";     StringContent filePostData = new StringContent(file["File"]["fileContent"].ToString(), Encoding.UTF8, file["File"]["contentType"].ToString());     var filePost = await spClient.PostAsync(requestString, filePostData); }  

The contentType of each file varies, while testing for example, I get back these file types:

application/vnd.openxmlformats-officedocument.spreadsheetml.sheet application/vnd.openxmlformats-officedocument.wordprocessingml.document application/pdf 

siteResponseObject is the response from creating the listItem which contains it’s ID and everything.

Does the sharepoint API expect to like a byte array? Am I encoding the StringContent object wrong?

Delete all post comments NOT attachment or page comments

I have this function that deletes ALL comments after X days. How can I edit this so that it only applies to posts, not pages or attachment pages?

function md_scheduled_delete_comments() { $  comments = get_comments( array( 'post_type' => 'post', 'date_query' => array( 'before' => '3 days ago', ), ) );  if ( $  comments ) { foreach ( $  comments as $  comment ) { wp_delete_comment( $  comment, $  force_delete = true );     } } } add_action( 'wp_scheduled_delete', 'md_scheduled_delete_comments' ); // You can test it immediately by adding following line: // add_action( 'wp_loaded', 'md_scheduled_delete_comments' ); 

How to show optimized list of posts with all their attachment images

In page-images.php template I have created this code which displays a list of posts which belong to a category and order them by meta value. So basically it is like a category page, generally nothing special except that each post isn’t shown as a single featured image but with all its images like this: enter image description here This code works but I ask myself how can it be more optimized? Since it has nested WP_Query. Page generates 100 queries and it should be a paginated list like this for each category and for many variations (depending on meta key).

$  query = new WP_Query( array(     'posts_per_page' => 25,      'cat' => 102, // Category ID     'meta_key' => 'rod', // Order by meta field value     'orderby'   => 'meta_value',     'order' => 'ASC',     'post_status' => 'publish',     'meta_query' => array( // Meta value should exists             array(                 'key' => 'rod',                 'value'   => array(''),                 'compare' => 'NOT IN'             )         )     ));  // Inside loop for each post get its images if ($  query->have_posts() ) {     while($  query->have_posts()) {     $  query->the_post();          $  args = array(             'posts_per_page' => -1,              'post_type' => 'attachment',             'post_mime_type' => 'image',             'post_status' => 'any',              'post_parent' => get_the_ID(),             'order' => 'DESC'             );         $  attachments = new WP_Query($  args);             ?>           <div class="col-md-10">             <?php // each loop has a title, meta field and images             <h2><?php echo get_the_title($  key); ?></h2>             <p><?php the_field('latinsko_ime', $  key); ?></p>              <div class="row">                 <?php while($  attachments->have_posts()) : $  attachments->the_post(); ?>                 <div class="col-md-3">                      <a href="<?php the_permalink(); ?>">                         <?php echo wp_get_attachment_image(get_the_ID(), 'category__loop', false, array('class' => 'img-fluid')); ?>                     </a>                  </div>                 <?php endwhile; ?>             </div>          </div>      <?php      }  } 

I have tried removing nested WP_Query and for each loop retrieve images like this $ gallery = get_post_gallery_images( get_the_ID() ); but in this case I have even more queries (127)