CRM2011: Open crm lookup from another application with customview - dynamics-crm-2011

I have custom application with active use of CRM lookups.
I can open CRM lookup from my JS like this:
function OpenLookup() {
var url = "http://CRM_SERVER_NAME/ORG/_controls/lookup/lookupsingle.aspx?class=null&objecttypes=2&browse=0&ShowNewButton=0&ShowPropButton=1&DefaultType=0";
var lookUp = window.showModalDialog(url, "entity",..);
...
}
How can I setup customView on lookup (typically it can be done using addCustomView(..) but I can't call any CRM Javascript (no CRM Javascript model on my form). Is this any way to do this?
I'm perfectly happy with any unsupported method.

Just a silly (or not) idea.
The lookup comes from an existing entity form so … why not open this CRM form (the inner IFRAME edit.aspx not the main.aspx) inside an IFRAME (hidden, resized) in your custom application ,wait until it loads and open the lookup from inside this IFRAME. This way you have access to the entire Xrm.Page model including addCustomView. You may also attach to this lookup field change event to get the selected value.
To make the IFRAME load fast you can create a new role form with only the lookup/s you need to pop and use this in your IFRAME.

Related

SharePoint WebPart zoneId

I am using SharePoint online.
I want to use this CSOM code to add a WebPart to a page:
SP.File oFile = _web.GetFileByUrl(SiteUrl + "/SitePages/" + pageName);
oFile.CheckOut();
LimitedWebPartManager limitedWebPartManager = oFile.GetLimitedWebPartManager(PersonalizationScope.Shared);
var importedWebPart = limitedWebPartManager.ImportWebPart(webPartSchemaXml);
var webPart = limitedWebPartManager.AddWebPart(importedWebPart.WebPart, zoneid, zoneIndex);
oFile.Update();
await SiteCtx.ExecuteQueryAsync();
oFile.CheckIn(String.Empty, CheckinType.MinorCheckIn);
The problem is how to assign correct values to the zoneid string variable,
which is the name of the Web Part zone to which to add the Web Part.
When I run this code nothing happens!
(it doesn't add the WebPart to the page and I am suspecting it is related to the wrong zoneId).
I have read various post, ranging from accessing the code behind of the .aspx page trying to find the WebPartZone, accessing the WebPartManager class (which should list the ZoneId's but I don't know how to get it, since that I am using the LimitedWebPartManager class).
I have tried various values for zoneId, but at the moment none of them work:
Zone 1 (just a guess!)
Zone 2 (i see it in the right tab when manually editing the webpart through Edit page)
Body (with this the code worked some days ago! but now it doesn't anymore)
Header
Left
Bottom
What is the proper method of findind zoneId's?
EDIT
The page is the homepage, I have read somewhere that it is a wiki page so maybe it has different ZoneId's.
ZoneIDs might be different depending on the page layout, but usually out-of-the-box SharePoint layouts use the following ID's for webpart zones:
TitleBar
Header
LeftColumn
MiddleColumn
RightColumn
Footer
Make sure that you invoke the update() method on your file object and executeQueryAsync() method on your context after importing the webpart - the latter function especially is responsible for sending the request to server and applying your changes.
Here's a nice article about adding webparts to pages programatically: How to programmatically add a ClientSide Web Part to a SharePoint page

Opening different xpages forms from a view panel

I have an Xpages application that pulls data from another .nsf file. I have a view panel linked to a view in that db. The view has documents with several different forms in it. I want to be able to open each document in it's own form(xpage).
How do I write a computed At Runtime, open selected document using: statement that will select the correct Xpage to present the document.
If you use the Data View component instead of a View Panel, you can compute the pageName attribute, referencing the var attribute to return a different value for each row based on the document that row represents. The flexibility of the Data View component also makes it easier to make your app look more like a modern web application and less like an Excel spreadsheet. As an additional bonus, the mobile theme invokes a renderer that makes each Data View instance look like a native mobile list, so using Data Views instead of View Panels simplifies mobile development.
You have 2 options:
use "use xpage associated with form" and edit the form's property
use a SSJS formula to compute the Form. You provide a variable name in the view control var to access a view row as XSPViewEntry. If the Form is in a view column even one you don't display you use .getColumnValue otherwise getDocument.getItemValueString
Does that work for you?
Maybe this mothed can help you: Unable to get document page name for
Hope this helps
Mark
I had a similar problem today. I use only one form but 3 different xpages for associated with this form. I have 3 different document types in the view. I used rowData the get the type of the document.
try{
var v=rowData.getColumnValue("form");
if(v.indexOf("x")> -1){var page ="x.xsp"}
else if(v.indexOf("y") > -1){var page = "y.xsp"}
else{var page = "z.xsp"}
}catch(e){
var page = "x.xsp"
}
So to your view you can create a column with the value of the form and you can use it.
I have used the extension library Dynamic View control which has an event you can code to get a handle to the NotesViewEntry which was selected. See the demo database page Domino_DynamicView.xsp and the Custom Event Handler tab for an example.
Note, in 8.5.3 (I have not upgraded yet) if you add or edit the eventHandler for onColumnClick it will be added to the XPages source as an xe:eventHandler. It needs to be an xp:eventHandler to work. The way to do it is to copy the code in the source from the exiting event and delete it. Recreate the event and update the code. Then go back into the source and change the tags within the eventHandler to xp:.

Modifying sharepoint edit dialog

I have successfully created a feature in sharepoint that modifies the existing edit dialog and adds a custom button to it like this.
and I am aware that I can pass back data when the user clicks the custom button like this.
<CommandUIHandlers>
<CommandUIHandler Command="ActivateUser" CommandAction="/_layouts/MyFeature/MakeUserActive.aspx?ListID={ListId}&ItemID={ItemId}&ItemUrl={ItemUrl}&ListUrlDir={ListUrlDir}" />
</CommandUIHandlers>
As detailed here
I can now handle the list item and perform my required actions on it BUT given that this button has been added in the modify context (IE: Inside the sharepoint edit item dialog) what if you want to save changes to the data itself?
To me it seems like using your custom button would always mean losing any changes the user has made to the data. Is there a way around this?
Good question!
You actually already linked to the solution: Right now you are simply redirecting the user by using a URL as your CommandAction: CommandAction="/_layouts/MyFeature/MakeUserActive.aspx?ListID={ListId}&ItemID={ItemId}&ItemUrl={ItemUrl}&ListUrlDir={ListUrlDir}"
This if course redirects the user to another page without saving the current entry. What you want to do is use Javascript as linked in the MSDN article:
CommandAction="javascript:alert('here be dragons');"
You can either work the the SharePoint Javascript object model here and use something like SP.ListOperation.Selection.getSelectedItems(); or you could use complete custom code.
From your aspx page name I can see you want to "make a use active" (btw: wouldn't "ActivateUser.aspx" be nicer?). If this simply means setting a property in another list you could do that with the SharePoint OM, if it is some custom stuff you would need a webservice which you can call from JavaScript and "activate the user" like that. You can of course always access the current form and pass on the values the user entered. Or you could create a custom save button which does some stuff (activate user) before saving.
Lastly: You can also have postbacks in your custom button where you could do anything you'd like.

sharePoint arcitecture custom action in list shown in pop up

this is an image of a sharepoint list action , the sending news letter is a custom action that i added , but when clicking on it , i want it to open a page not redirection, i want it to get a pop up action with a mask behind as the View item do
What you are referring to is the modal framework in sharepoint 2010. You need to change your action javascript code.
Here is an article i've used in the past.
http://www.chakkaradeep.com/post/Using-the-SharePoint-2010-Modal-Dialog.aspx
You need to call ModalDialog Javascript function from your CustomAction rather than redirection.
Here's the URL with example of what you are looking for:
http://www.chakkaradeep.com/post/Using-the-SharePoint-2010-Modal-Dialog.aspx

Need some help with sharepoint web part development

I have a custom web part where there is a text box. My custom web part also has a custom setting where user enters some values separated by commas. So on load, the UI should display the values entered in the setting (without commas though).
Is this possible with normal ascx user control, since it cannot access the sharepoint web part property at the time of creation and hence cannot display the message on load.
Need some help to solve this.
Thanx
I assumed you're probably doing something like this.
What you'll need to do is pass your web part properties to your usercontrol. You can do this by creating public properties in your usercontrol class (demonstrated in the link I give above).
Code sample from the article:
// Loads a user control
MyUserControl myUserControl = (MyUserControl)Page.LoadControl("~/_controltemplates/MyWebPart/MyUserControl.ascx");
myUserControl.Web = SPContext.Current.Web;
myUserControl.TextColor = this.TextColor;

Resources