Quantcast
Channel: Aviv Roth
Viewing all articles
Browse latest Browse all 15

Persistence

$
0
0

It seems that some of the success in coding comes from no more than persistence. A lot of what I do to get stuff to work takes trial and error.

For example: I was trying to get something modified in SharePoint 2010: specifically, make it so that when the user uploaded a document, the user wasn’t also prompted to fill in a form of metadata fields (I wanted the fields to be populated programmatically). I was stumped, so I hit the Googles.

I found this page, which, frankly, was confusing as hell, owing probably to the non-native English of the posters (don’t get me wrong, I have SUPREME respect for non-native English speakers who regularly use the ‘net to find technical information). I tried some of the sample code, but nothing worked. One poster suggests putting the code in a web part at the end of the web form, and another more towards the beginning. There’s also about 4 samples of code to use.

So I actually resorted to trial and error. Trying various code blocks both before and after the web part in question. It took me a while, but I finally got it to work. What I had to do was combine the code from one post and the placement of the code from another post. And voila.

So what am I trying to convey, other than how much SharePoint can suck?

Mostly, that it’s about not giving up. Fanatically trying something, and if it doesn’t work, trying something else, and if that doesn’t work, trying something really nuts and out of the box until maybe that works. It doesn’t matter what I’m working on, or how good the platform is, or how much of an expert I am in the platform.

That’s the key in this line of work. Try and try again, and be willing to color outside the lines and try whatever crazy idea you can think of to get it to work.

Persistence.

(Just in case you surfed here looking for a similar answer to the SharePoint issue, here’s exactly what to in SP 2010:

  1. Navigate to the doclib in question in your browser
  2. On the ribbon, under “Library”, select “Form Web Parts”->”Default Edit Form”
  3. When the webpart edit form comes up, click on “Add a Web Part”
  4. From “Categories” select “Media and Content”, and from “Web Parts” select “Content Editor”
  5. Click “Add” on the right
  6. Put the cursor inside the “Content Editor” web part that has been added to the form
  7. From the Ribbon, select “HTML”->”Edit HTML Source”
  8. Copy and paste the following JS code into the popup window:
    <script type="text/javascript">
        function GetQueryStringArgs() {
            //fetch querystring and remove first ?
            var qs = (location.search.length > 0 ? location.search.substring(1) : "");
            //create an object for saving data
            var args = {};
            var items = qs.split("&");
            var item = null,
                name = null,
                value = null;
            //add to args object one by one
            for (var i = 0; i < items.length; i++) {
                item = items[i].split("=");
                name = decodeURIComponent(item[0]);
                value = decodeURIComponent(item[1]);
                args[name] = value;
            }
            return args;
        }
        var args = GetQueryStringArgs();
        var urlReferrer = document.referrer.toString();
        if (urlReferrer.indexOf("Upload") != -1) {
            window.frameElement.commitPopup();
        }
    </script>
    

  9. Click OK
  10. That’s all. The next time a user uploads a document, no edit form will appear.)


Viewing all articles
Browse latest Browse all 15

Trending Articles