While developing SharePoint application, you may want to use PeopleEditor control or your own custom control derived from EntityEditorWithPicker. If you come across the problem with setting its value using Javascript, below is the code sample that may help.
<script type="text/javascript">
function SetPickerValue(pickerid, key, dispval)
{
var xml = '<Entities Append="False" Error="" Separator=";" MaxHeight="3">';
xml = xml + PreparePickerEntityXml(key, dispval);
xml = xml + '</Entities>';
EntityEditorCallback(xml, pickerid, true);
}
function PreparePickerEntityXml(key, dispval)
{
return '<Entity Key="' + key + '" DisplayText="' + dispval + '" IsResolved="True" Description="' + key + '"><MultipleMatches /></Entity>';
}
</script>
The easiest way to set PeopleEditor’s value is to use the EntityEditorCallbak function. This function is provided with built-in SharePoint javascript functions (both WSS 3.0 and MOSS 2007). It is the same function that is used by the control to set its own value. The first two parameters of the function are important – the first one is XML containing entities definition and the second one is a client identifier of the control which value should be set. (The client identifier is the same which is available in the ClientID property on the server side).
The above code sample presents the SetPickerValue function. The function covers XML generation from a given key and display text, and calling of EntityEditorCallback function.
Example of SetPickerValue call:
SetPickerValue('ctl00_PlaceHolderMain_pplEdit', 'domain\\m.kapusta','Marcin Kapusta');
Generated XML (for the given call) is the following:
<Entities Append="False" Error="" Separator=";" MaxHeight="3">
<Entity Key="domain\m.kapusta" DisplayText="Marcin Kapusta" IsResolved="True" Description="domain\m.kapusta">
<MultipleMatches />
</Entity>
</Entities>
Be careful when providing domain account name. Javascript treats \ (backslash) character as a special character. If you want to have it in the string, you have to use \\ instead. That’s why I had to provide ‘domain\\m.kapusta’ as a parameter to get domain\m.kapusta value in the XML.
If you want to set PeopleEditor value to have multiple entities, you can modify SetPickerValue function to generate multiple <Entity /> nodes in the XML.
You can set IsResolved attribute to False to have unresolved entity in the control. When the entity is unresolved you are able to provide some suggestions (accessible in the popup menu) adding child nodes to the <MultipleMatches /> node. I don’t want to go into details about the multiple matches as it is the topic for another post.
2009-07-26
Hajduk Split Supporters
Today I was watching TV series about cuisine from all the quarters of the globe. The Episode was about Croatian cuisine and it took place in Split. While the presenter was cruising around the city, he was passing a huge Hajduk Split logo on the stone wall. Hajduk Split is a Croatian football club, one of two most popular football clubs in Croatia. The other one is Dinamo Zagreb. These two are the biggest competitors in Croatian First League. As year follows year they exchange as the league champion. OK, but let’s get back to the point - the presenter mentioned a nice story about inscriptions on the walls made by Hajduk supporters.
When Jan Paul II was visiting Split, there were inscriptions in many places saying “Hajduk Split firs, Jan Paul second”. They say that Jan Paul II was laughing when he saw those sentences on the walls. When the next pope – Benedict XVI was visiting Split, Hajduk supporters also showed their creativity. That time inscriptions were saying “Benedict sixteenth, Dinamo seventeenth” (as you can suppose, it was about Dinamo Zagreb).
I wish Polish supporters where so creative. Unfortunately they usually limit themselves to words: King, Sucks and few F.. words.
When Jan Paul II was visiting Split, there were inscriptions in many places saying “Hajduk Split firs, Jan Paul second”. They say that Jan Paul II was laughing when he saw those sentences on the walls. When the next pope – Benedict XVI was visiting Split, Hajduk supporters also showed their creativity. That time inscriptions were saying “Benedict sixteenth, Dinamo seventeenth” (as you can suppose, it was about Dinamo Zagreb).
I wish Polish supporters where so creative. Unfortunately they usually limit themselves to words: King, Sucks and few F.. words.
2009-07-21
Having fun at work?
Yesterday I wrote about charging batteries. I mentioned there that one of the way to do so is having fun. In my opinion it is the most powerful way. But probably even better way to keep your effectiveness and motivation up is having fun doing your work.Probably less than a quarter (and I am quite sure that less than half) of working people really like their jobs. Most of us treat a job only as the way of earning money for living or even as a necessary evil. But sometimes it is possible to have at least a bit fun of your work. Of course it depends on the job you do.
Here are few tips that I use to be more satisfied with my job:
- Try to achieve the goals your way.
- Do things right.
- Not be afraid of new challenges.
- If you have a choice, choose tasks that require learning new things from you.
You can find a great example of having fun in the Queen Breakthru video. It is not related to the above tips, but it always crosses my mind when I think about fun at work. Every time I watch it, I think: “shooting this video had to be great fun for all of them”. The statement isn’t only about Freddie. Just have a look at John Deacon and Brian May in a take starting at 1minute 25th second. Each of them is showing it his own way. I like John’s best.
2009-07-20
Charging Batteries
Last week I heard a nice story about Jan Paul II the pope. His most favorite day of the week was Tuesday. It was his day off. I was surprised that popes have days off. He wasn’t doing nothing during these days of course, but he liked to have Tuesdays for himself. Every other day he was giving part of himself to others. So he needed one day to recover his energy. If you are empty, you have nothing to give from. It was his way to avoid this.The story reminded me my last holidays and an interesting situation that I had at work during last few weeks. About 3 weeks ago I had a quite exhausting period. My brother-in-low with his girlfriend, their dog, and our nephew were visiting us for a week. We were planning and organizing our holidays’ trip at home and I had urgent issue to solve at work. Everything at the same time. After 3 long days of researching the issue at work, I was thinking I knew the solution. But every time I was starting to write the code - an unresolved problem occurred. It was the same with every aspect of the issue. I was frustrated. Really.
And then my holidays started. I spent a week swimming, sunbathing, reading books, playing cards and sports. No computer and no TV for the whole week. I came back so fresh and receptive. I just got the second wind. The funny thing is that after the next 3 working days all problems were solved and the solution was ready. You may say it was a coincidence, but I think I just had to recharge my batteries and refresh my mind.
The clue is that if you want to keep your effectiveness and motivation on a decent level, remember to charge the batteries. Here are my favorite and proven ways to do so:
- Take advantage of the weekends. If you have to work during weekends, have at least one day off a week.
- Have longer (1-2 weeks) holidays from time to time. Especially after hard or frustrating period.
- Have fun as often as possible. It helps to get rid of stress and refresh your mind.
- Do sports – it is, in fact, an alternative of having fun, but very straightforward and easy to approach.
2009-07-19
Hello World
It is time to start blogging.
I created this blog account in the beginning of 2007. Wanted to share my opinions on technology, software management, best practices, team work, friendly workplaces and anything else related to software development process and working with people. Probably few things more...
As you can see my first post appeared Today. Why? During last 4 years I was working for a Polish software corporation, creating ERP system. Started as a software developer, but in 2007 transferred to API architect, team leader and finally to production manager. All of these turned out to be very interesting and instructive, but also quite time-consuming.
Recently I changed my job and moved to a small resilient company, delivering ASP .NET and SharePoint solutions. Mainly documents flow and workflow systems. First contact with SharePoint and ASP .NET brought my mixed fillings out. Undocumented and not always clear API and solutions sometimes made me feel so helpless and lost. Thankfully uncle Google helped (as always).
During the last 3 months most of the answers I found on blogs. And that reminded me about this blog. It’s time to stop educate myself only and start to share things I have learned. I hope my blog entries will help You find answers, ideas or anything else that make You reading blogs.
I also hope, I won’t keep my pace and post only one entry every two years :-).
I created this blog account in the beginning of 2007. Wanted to share my opinions on technology, software management, best practices, team work, friendly workplaces and anything else related to software development process and working with people. Probably few things more...
As you can see my first post appeared Today. Why? During last 4 years I was working for a Polish software corporation, creating ERP system. Started as a software developer, but in 2007 transferred to API architect, team leader and finally to production manager. All of these turned out to be very interesting and instructive, but also quite time-consuming.
Recently I changed my job and moved to a small resilient company, delivering ASP .NET and SharePoint solutions. Mainly documents flow and workflow systems. First contact with SharePoint and ASP .NET brought my mixed fillings out. Undocumented and not always clear API and solutions sometimes made me feel so helpless and lost. Thankfully uncle Google helped (as always).
During the last 3 months most of the answers I found on blogs. And that reminded me about this blog. It’s time to stop educate myself only and start to share things I have learned. I hope my blog entries will help You find answers, ideas or anything else that make You reading blogs.
I also hope, I won’t keep my pace and post only one entry every two years :-).
Subscribe to:
Posts (Atom)