i want to show an error message, whenever the user adds an item.
So i use code similar to that:
public override void ItemAdding(SPItemEventProperties properties)
{
properties.Cancel = true;
properties.ErroMessage = properties.AfterProperties[columnname];
}
Unfortunately it only work, when the columname ist an default column.
For self defined columns it doesn't work.
I get this error message:
event receiver has canceled the request
I tried everything:
The columnname is right, the column is not null,..
If i write a console application getting this columns, everything will work well.
Only in the event receiver it doesn't work.
Can anybody help? Would be great!
hopefully not too stupid a question but are you using a column name that SharePoint recognizes? The reason I ask is that you mention that these are self defined columns. When you define a column via the UI, the column name behind the scenes ends up as something similar but not the same.
This page gives you a bit of an over view of DisplayName vs InternalName. And as the author mentions, things get even more complicated when you rename a column via the UI.
Related
In Work order tracking application in actuals tab materials section when user clicks on New row by default the transaction type = ISSUE . I would like to change this by default to RETURN and remove issue from the look up (I was able to remove ISSUE from the lookup). This requirement should only work for PM type work orders. Hence I tried to write an automation script on MATUSETRANS.ISSUETYPE attribute launch point however it throws null pointer expection which trying to perform setValue. I tried using 2L,7L and 11L however it doesn't work.
if(onadd) ==True:
mbo.setValue("ISSUETYPE",'RETURN')
Is there any other way to do this?
We basically need to trigger the code on a field that sets after ISSUETYPE is set using the out of the box code so I tried on field like currencycode or condrate (attribute launch point) and it works like charm. You will have to use 7L though to the existing code.
Preamble: the last time I had an issue with something from the extension libraries, I immediately posted a bug report on openNTF.org. It then turned out that I had missed a property setting that made everything work perfectly. To prevent this issue from happening again, I decided to post the question here first, can anyone reproduce the error that I am having, or am I missing a property on the xe:DynamicViewPanel control?
tested ExtLib versions tested:
901v00_06.20140424-0600
901v00_02.20131212-1115
Domino/Notes version used Domino 9.0.1
Steps to reproduce
Create a dashboard XPage application. - data is stored in a different database.
Using a dynamicViewPanel control, access a database that lies ON THE SAME SERVER and show information from that database in the view.
Click on a document link in the dynamic view panel and look at the URL in the browser. When the dynamicViewPanel is pointing to a view in a different database hosted on the same server as the dashboard, the url looks like this : http://path/Portal.nsf/%24%24OpenDominoDocument.xsp?databaseName=CN=Maestro/O=hol-dev/C=DE!!path/Portal.nsf&documentId=A6727D8AF7D2FE19C1257C9E0034A14C&action=editDocument
The appropriate Xpage defined by the form name of the document being clicked on will open and the data saved in that document will even be loaded.
Click on a button that performs any action with the defined document datasource. It can be as simple as printing a string to the server when notesXspDoc.isNewNote(). You will get an error message saying that (in the case above) NotesXSPDocument.isNewNote() null. This means that the variable IS NOT null, but for some reason you are getting a null error response.
This error will only happen when the dashboard and the data database are on the same domino server. As soon as one of them are moved, it will work perfectly AND the URL will be correctly written; the server name of the databaseName parameter will be written in the abbreviated way.
In an attempt to understand/fix this issue, I took a closer look at the code in the Extension Library class com.ibm.xsp.extlib.component.dynamicview.UIDynamicViewPanel. There, I found the call to super(XspViewPanel).getDocumentUrl(). My guess is that the error lies in that function, but that is not a class that is defined by the ExtLibs. At the very least I would be interested to know what is written there.
educated guesswork
I am pretty certain of the following: The page when first open loads because key information is saved in the requestScope. This information is not not passed on to the java DominoDocument object which is created by the NotesXspDocument javascript 'class'. When (in the background) the DomDoc.restoreDocument() function is called, it tries to locate the database CN (as returned by the param.get("databaseName") function) and fails. Thus, no further function can be called on the object since an exception would always be thrown. (This is all an educated guess on my part)
My Questions clearly stated
Is this a known bug and I am just not finding it in my google searches?
Am I just not seeing a property of the ViewPanel that would fix this error?
Is there a better work around other than setting the "ignoreUrlParams" property of the document data source and calculating the server/documentID?
Thank you very much for all assistance given!
EDIT
Changing the "ignoreRequestParams" property to true and calculating the databaseName and the documentID does not make a difference at all. I am really confused as to why it does not work, I would think that calculating the source information and not paying any attention to the request parameters would solve it, but i am having the same issues. Any further assistance would be greatly appreciated!
After a great deal of testing, deleting functions and re-adding them, I think I have the answer I sought. I cannot really say why this is, and I find it a crappy design if my thoughts are correct.
I found that when I commented out a certain javascript line which opened the database in a background java class to find out the user's current roles, it worked again. Upon further investigation, when I took out the java lines that recycled the source database, the dashboard worked again. This means, however, that the background c++ object is still existing in the background somewhere. In this project, it seems to only be an issue when the source DB and dashboard DB are hosted on the same server.
I am going to answer my question with "No, this is not a bug in the dynamicViewPanel", but rather a questionable design from IBM itself. Either we should be recycling our Notes objects, or we should not be recycling our Notes objects, or we should be given a very detailed description of when and when not to recycle. Maybe I am just not used doing my own GC. Here is the code that was giving me a hard time (some variable names have changed to protect the anonymity of the customer):
public String getDatabaseRoles(){
Session session = null;
Database db = null;
Vector<String> roles = null;
try {
session = SessionHelper.getCurrentSession();
db = DatabaseController.getApplicationInstance().getDbFile().getDatabase();
roles = db.queryAccessRoles(session.getEffectiveUserName());
} catch (NullDatabaseException e) {
// already logged
} catch (NotesException e) {
ErrorWriter.getSessionInstance().writeError(new Date(), ErrorLevel.ERROR, "EprDatabaseController.getDatabaseRoles()",
e);
} catch (NullSessionException e) {
// already logged
} finally {
//if(db != null) try {db.recycle();} catch(NotesException e) {} //commented out due to issues when portal is on same server as data.
//if(session != null) try {session.recycle();} catch(NotesException e) {}
}
StringBuilder roleStr = new StringBuilder();
if(roles != null){
for(String role : roles){
if(!StringHelper.isNullOrEmpty(role)){
roleStr.append(role);
roleStr.append(":");
}
}
}
ErrorWriter.getSessionInstance().writeError(new Date(), ErrorLevel.TRACE, "DatabaseController.getEPRDatabaseRoles()",
"Database Roles: " + roleStr.toString());
return roleStr.toString();
}
Again, just so workarounds are already answered for future readers,
have the source database on a different server.
set the ignoreUrlParams property of the document datasource and calculate the the documentID and databaseName correctly inserting the server name as abbreviated.
This not being the true answer of my question, I am just putting this here for future user ease.
I'm having trouble with the webparts variables... I came from standard ASP language, so, to me, store variables in session and other parts is the common way to do everything =)
Now i had to create a webpart, the wp has to write a graph from parameter and i cannot understand HOW variables works: i cannot understand WHEN saved and WHEN erased and other thing like this!
Let me explain: i have a web part with the configuration toolbar on the right in which i put the values.. Everytime a button is pressed or a value in the dropdown list changes, it raises an event which causes the "CreateChild" function..
Many times the data is "stored", other time they are not!
That's the way i used to store value (in the ApplyChanges override function):
WPChartGenerator wpParent = (WPChartGenerator)this.ParentToolPane.SelectedWebPart;
wpParent.WebUrl = txtWebUrl.Text.Trim();
And in the CreateChild event i get the value like:
WPChartGenerator wpParent = (WPChartGenerator)this.ParentToolPane.SelectedWebPart;
this.ddlWeb = new DropDownList();
this.ddlWeb.ID = "ddlweb" + wpParent.ID;
ddlWeb.SelectedValue = wpParent.WebService;
Now.. Sometimes this works, for example, when i push a button I invoke in the code of the button and then the code to store every value.. In some case (like buttons) this works, in other (like dropdown list index changed event) this fails and i found every object in the wpParent equal to it's initial value.
Another thing i noticed, is that in certain cases when an event is triggered, the first thing to be executed (even first than the event's associated code) il CreateChild (even first than OnLoad!!!)
Can anybody tell me what I'm doing in the wrong way? Do anybody has a good tutoria for this matter?
Thanks & sorry 4 my School level English =)
Forget to say that every variable has been implemented as a Property, like that:
[WebBrowsable(false)]
[Personalizable(PersonalizationScope.Shared)]
[WebPartStorage(Storage.Shared)]
public string WebUrl
{
get
{
return this.webUrl;
}
set
{
this.webUrl = value;
}
}
I can't see all the code there so I don't really know what you're doing wrong (i.e. do you actually have an ApplyChanges method) but from the way you've worded your question it sounds like you really need to start at the beginning, follow one of these walkthrough tutorials and make sure you understand the basics and then start adding in the code for your project.
MSDN - Creating Web Parts for SharePoint (VS2010)
MSDN - Walkthrough: Creating a Basic SharePoint Web Part (WSS 3.0)
Developing SharePoint 2007 Web Parts
I'm experiencing a very stubborn problem when copying custom content type and its columns from one web to another within the same site. Basically, this is the code that I have:
foreach (SPField field in existingWeb.Fields)
{
if (!destinationWeb.Fields.ContainsField(field.Title))
{
destinationWeb.Fields.AddFieldAsXml(field.SchemaXml);
destinationWeb.Update();
}
}
foreach (SPContentType existingWebCt in existingWeb.ContentType)
{
SPContentType newContentType = new SPContentType(existingWebCt.Parent, destinationWeb.ContentTypes, existingWebCt.Name);
foreach (SPFieldLink fieldLink in existingWebCt.FieldLinks)
{
SPField sourceField = existingWebCt.Fields[fieldLink.Id];
if (destinationWeb.Fields.ContainsField(sourceField.Title))
{
SPFieldLink destinationWebFieldLink = new SPFieldLink(destinationWeb.Fields[sourceField.Title]);
newContentType.FieldLinks.Add(destinationWebFieldLink);
}
}
}
existingWeb and destinationWeb are 2 webs within the same site. The code runs fine. But the problem is that in the SITE Content Type screen (under site settings), when I click the custom column link in the custom content type, I got an error saying:
Invalid field name {UID}.
The UID is the same UID as the custom column in the existing site. I checked with my web settings after completion. I can see the custom list (which I created with an item for testing purpose), but the custom column is gone from the view (though the actual data is still there... just have to check the box to get it to display). But I think that is less important... more of fyi.
I've also gotten a variety of different exceptions should I copy things wrongly. Google has failed to help me out on this one.
Does anyone know what I'm missing in order to get that link to work again?
Thanks.
Gary lapointe tackled content type copying already, and it turns out it's a doozy: http://stsadm.blogspot.com/2007/08/copy-content-types.html
Check it out and see if there's anything you may have missed
Say I have a custom field type called MyCoolField that I have deployed in a solution. This solution also contains a SPEventReceivers that has overridden ItemAdded, ItemUpdated, and ItemDeleting. All the specifics of this particular field type are probably not super relevant, but one thing to note is that inside of the OnAdded method it attempts to add a series of event receivers to its ParentList.
After this solution has been deployed, I activate a site-scoped feature that does nothing except add a new site content type - MyContentType. Now, I would not expect any event receivers registered anywhere, since ParentList is supposed to be null for site content types.
So in yet another feature, I go add this MyContentType to a list. The question I have is whether I should expect the OnAdded method to get called now (when adding a content type to the list) or does it only get called when adding the field to list/content type? It seems like it is not getting added (the event receivers are not getting registered), but I wanted to make sure that is truly expected behavior and not something else odd going on in this environment.