SharePoint Designer | @SPJeff

Manually Run “Pause Until” SharePoint Designer Workflows

May 15, 2012 in Uncategorized

Recently I needed to simulate a future lapse in time in order to manually trigger the “Pause Until” SharePoint Designer function.  In the example below, the SharePoint server is a local DEV virtual machine running in Oracle VirtualBox.  That means it receives time from the parent machine.

 

Action Steps

  1. Move VM host clock forward 1 day (24hours)
  2. Move VM guest clock forward 1 day (24 hours)
  3. Run the Powershell command “Get-SPTimerJob | ? {$_.name –like ‘*workf*’} | Start-SPTimerJob

 

What the above steps will do is to simulate a future date and then trigger the SharePoint workflow engine.  If the engine finds any past-due activities (ex:  “Pause Until ___”) then it will execute those immediately.  Using this technique you can build “Pause Until ___” workflows and still test them to ensure everything completes as expected, without having to actually wait the full time.  Smile

 

image

image

image

image

SPD Best Practice: Ctrl C+V Quick Backups

October 9, 2009 in Uncategorized

To quote Asif Rehmani (@asifrehmani) from www.sharepoint-elearning.com … “SharePoint Designer is like a really sharp knife.   It’s very good at what it does.   You might cut yourself.   But you don’t stop, just act more carefully.”

 

With that lesson well learned over my years with SharePoint customization I must say my favorite trick of all is the simple quick copy/paste backup.   Any time and every time I’m about to jump off a cliff to dive into SPD coding I perform a Quick Backup:

  • Highlight the file
  • Ctrl+C    (copy)
  • Ctrl+V    (paste)
  • Breathe a sigh of relief

Storage is cheap.   Mistakes are not.   Time is one of our most scarce resources.   Buy some insurance with a Quick Backup!   Hot

 

image

image

_WPQ_ with Javascript for dynamic lookup

August 4, 2009 in Uncategorized

If you’re using the trusty CEWP (Content Editor Web Part) to locate the current web part frame on a page you’ll want to consider using the “_WPQ” expression instead of hard coding a number.    Using the Internet Explorer Developer toolbar or Firebug toolbar is a great way to locate <DIV> tags and “ID=” attributes with a single click.

However, don’t be tempted to code in the number.    As you re-order web parts they will changes.    If you add more than one CEWP (export/import) the others will fail.    Use a dynamic token for maximum flexibility.

SharePoint’s rendering engine does a search replace on “_WPQ_” to give it the number of that web part on the page.   It’s a great way to avoid naming conflicts and a trick I’ve used to apply multiple JQuery driven CEWP on the same page.

 

References

image

URL Source= for Thank You on Submit

June 10, 2009 in Uncategorized

Many times I’ve been asked to adjust the NewForm.aspx (add record) experience for users to display a custom message after submit.    A “Thank You” page for a survey is a great example.    Other times in request forms people want to show a confirmation or instructions page.

Thankfully the SharePoint product team made this easy for us developers.

Action Steps

  1. Visit the list or library you’d like to tweak
  2. Click on New item to get to /NewForm.aspx
  3. Take a close look at the URL and notice the word “Source=”
  4. We’ll come back to this in a minute
  5. To create a “ThankYou.aspx” page I like to duplicate the “DispForm.aspx” by going into SharePoint Designer
    1. Right click Copy on DispForm.aspx
    2. Right click and Paste
    3. Edit the file to remove the main web part
    4. Rename the file to “ThankYou.aspx”
  6. Edit the part after the equals sign (=) from #3 and replace with a URL you’d like to take people to after submit

 

Often the destination page for #5 above doesn’t yet exist.   So you’ll want to open SharePoint Designer 2007 and create a new ASPX page to hold a “Thank You” message.    For this I always place the ASPX file in the same /Forms/ folder as the list I’m working on.   

Why?    By placing a custom ASPX in the same /Forms/ folder it will be including in any List template (.STP) creation and is easier for future admin and dev staff to locate for troubleshooting.

 

 

image

 

image

 

image

 

image

image

 

image

 

image

 

image

 

image

 

image

 

image

 

image

MOVIE – Random Tip – XSLT

March 11, 2009 in Uncategorized

So you want to display a single random item from a SharePoint list?     It’s a common request and a very handy one for visitors.    Give your site a fresh relevant appearance with a dynamic web part.    Web 2.0 requires us site designers to keep pace with visitor expectations.   Let’s get to the fun part.    Here we’ll be using the Data Form Web Part (DFWP) sometimes called the Data View Web Part (DVWP) to present a SharePoint list with XSLT logic for the randomizer and conditional formatting to only show the target record.

Example Code   (random row XSLT.txt  1KB)
Sample Data     (Email Security Tips.xls  13KB)

 

Watch this 4 minute movie clip to see a live demo.     Steps are outlined below also.

 image

 

  1. Create your list
  2. Open the target page in SharePoint Designer 2007
  3. Open Data View Manage Data Sources
  4. Ctrl+Click the Title and Body columns     (NOTE – other column names work too)
  5. Drag them on the page
  6. Add two CSS classes to the page header

    <style type="text/css">
    .showMe {
        visibility:visible;
    }
    .hideMe {
        visibility:hidden;
        display:none;
    }
    </style>

  7. Locate the XSLT header with “<xsl:variable” entries and confirm you have the below three:

    <xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row"/>
    <xsl:variable name="dvt_RowCount" select="count($Rows)"/>
    <xsl:variable name="dvt_randomRow" select="ddwrt:Random(1,$dvt_RowCount)"

  8. Locate the <TR> for starting a new row.   Add the conditional pair below to apply the right CSS class when needed.

    <tr>
        <xsl:if test="position() = $dvt_randomRow">
            <xsl:attribute name="class">showMe</xsl:attribute>
        </xsl:if>
        <xsl:if test="position() != $dvt_randomRow">
            <xsl:attribute name="class">hideMe</xsl:attribute>
        </xsl:if>

  9. Apply extra formatting  (bold, colors, icons) to achieve a unique look for your audience.

JQuery Accordion – Expand Collapse All

March 9, 2009 in Uncategorized

I looked over many threads and posts on many sites and wasn’t able to find code that worked for me.    Some of it would be close.   Others buggy.   Below I’ve outlined the JQuery code that worked perfectly for my needs and I hope you find it helpful too.

This example was deployed to a SharePoint page so the “/_layouts/images/plus.gif” was used to leverage the OOTB graphics for a plus/minus icon feel.

Full Example Source Download     (accordion.zip  73KB)

 

image

 

image

 

Parent .HTML

<div id="container">
<div id="expand" style="text-align:right"><IMG src="/_layouts/images/plus.gif"/> Expand All</div>

<h3 class="headline"><a href="#">First Header</a></h3>
<div class="section">first body</div>

<h3 class="headline"><a href="#">Second Header</a></h3>
<div class="section">second body</div>

<h3 class="headline"><a href="#">Third Header</a></h3>
<div class="section">third body</div>

</div>

Supporting .JS

// bind to accordion object
$(document).ready(function(){
    $(‘#container’).accordion({
    header: "h3"
    });
});

// actions taken upon clicking the expand all (collapse all) link
$(‘#container #expand’).click( function() {
        // if link was expand then show and toggle text
        var currHTML = $(‘#container #expand’).html();
        if (currHTML.indexOf("Expand All")>0) {
                $(‘#container .section’).slideDown();
                $(‘#container #expand’).html("<IMG src="/_layouts/images/minus.gif"/> Collapse All");
        }
        // if link was collapse then hide and toggle text
        else {
                $(‘#container .section’).slideUp();
                $(‘#container .section’).each(function(i){
                    if (i==0) $(this).slideDown();
                });
                $(‘#container #expand’).html("<IMG src="/_layouts/images/plus.gif"/> Expand All");
        }
});

Could not find the file Exportsettings.xml

February 28, 2009 in Uncategorized

Could not find the file ‘C:WINDOWSTEMPf611fafc-73d8-4b48-bc1e-f9ef6d7cb991Exportsettings.xml’

This error message comes up when performing a SharePoint Designer 2007 site export and import above 25 MB.     There are some helpful blog articles already written on this like farhanfaiz’s post with a sample XML file with cabsdk workaround.     And this Technet post encourages server side changes to allow for larger files.    However, you might find yourself like me without server access and unable to resolve the issue.

Backup Steps

  • Open SharePoint Designer to the source site
  • Click [ Site Administration Backup Web Site ]

image

  • Provide a local file name to save output
  • Do not trust the success message.  If your site was over 25 MB it actually just failed.   Delete the CWP file, it’s worthless.    image

image

  • Browse to the site’s Recycle Bin and restore all of the files with a crazy GUID number prefix

image

  • Open the site’s root folder in SharePoint Designer
  • Highlight these GUID files, right click Publish, and send them to your local file system

image 

  • Create a New Folder on the local file system
  • Extract the content of all the CMP files to this folder
  • Use [ CABARC N newfile.cmp *.* ] to build a single large CMP file
  • This new CMP file contains all of the files of the disparate ones.    It’s easy to manage and provide a reliable import mechanism.
  • If restoring to another MOSS farm first move this new CMP file to that remote machine

image

 

Restore Steps

  • Open SharePoint Designer to the target site
  • Click [ Site Administration Restore Web Site ]

image

  • Browse for [ newfile.cmp ]
  • Enjoy seeing the restored files in the target site’s home folder
  • Go open a cold beer!    image

 

NOTE:   You can also use [ STSADM -O IMPORT -URL FILENAME newfile.cmp ] for the restore if you have console access on the destination MOSS server.

 

NOTE:   If the target MOSS farm lacks Feature Definitions (SPFeature) the source had activated the import will fail.   To resolve you can:

  1. Install the features
  2. Open the Manifest.xml and Requirements.xml inside of the CMP to remove those references with Notepad.    Re-create the CMP with CABARC and then run the import again.

MOVIE – Sales Figures – Data View with Conditional Formatting

February 2, 2009 in Uncategorized

In this brief movie clip I walk through how to create rich Data View Web Parts with Conditional Formatting to provide a smarter display of numerical data.   Colors and icons helps readers to better understand the data than what numbers alone can do.

image

image

Thank you for watching and please leave any feedback in the comments for my future posts.

Return to Top ▲Return to Top ▲