Dynamics CRM Dialog hangs/freezes when called via script - dialog

when dialog process is called from a script that is embedded on a ribbon button, The dialog freezes and enter into a not responding state.

I just figured out that When calling the dialog via script check the ObjectId Guid that it passes. If the provided Guid does not exist on CRM Database the dialog will hang without giving any error. This may happen if you want to create a dialog that do not need a entity record to run against. In this type of case you just want an inactive record to appointed as ObjectId.
function CallDialog()
{
var clientId = Xrm.Page.context.getClientUrl();
var url = clientId + "/cs/dialog/rundialog.aspx?DialogId=%7b460ACCDC-701C-4947-8E72-CDE2C53807FC%7d&EntityName=EntityName&ObjectId=%7b115fbb02-b5a5-e711-8122-005056b32967%7d";
window.open(url,"", "width=700,height=600");
}

Related

IBM Domino 10 - Java XPage create session or compare credentials of another user

I'm writing Java code in an XPage Rest Service basing on https://setza-projects.atlassian.net/wiki/spaces/RSD/pages/44007659/IBM+Domino which is an REST service written in Java used to handle Resource Reservations database. However the way it currently works, it creates the reservations for the current session user only:
private JsonObject createIntanceAppointment(ResourceDefinition rd, Database reDatabase, Date dtStart, Date dtEnd, String subject) throws NotesException {
Session session = reDatabase.getParent();
Name nnOrganizier = session.createName(session.getEffectiveUserName());
Name nnREsource = session.createName(rd.getFullName());
DateTime dt_startDateUTC = session.createDateTime(dtStart);
DateTime dt_endDateUTC = session.createDateTime(dtEnd);
Document doc = reDatabase.createDocument();
doc.replaceItemValue("form", "Reservation");
doc.replaceItemValue("Purpose", subject);
doc.replaceItemValue("ReservedFor", nnOrganizier.getCanonical());
doc.replaceItemValue("ResourceName", nnREsource.getAbbreviated());
doc.replaceItemValue("ResNameFormat", nnREsource.getAbbreviated());
I'm doing a very similar integration with Domino, although I'd prefer to have the reservations created for individual users (they provide their username & password on the room-booking application on a touch screen).
I could just authenticate as the user in my REST client, but if I understand the installation requirements for that RoomZ api correctly, the 'api managing user' needs to be exclusively signed to the database, so I would need to do that for every user in Domino that could make reservations.
I tried using NotesFactory.createSession("", "user", "password"); but that doesn't work, it gives Cannot create a session from an agent error
If I cannot create another session, is there any way I could verify that the username and password passed to the API in the payload is correct (to verify if the user can login)? Then I could just set the organizer/reserved for to this user.
Also, is there any way to make these reservation also appear in the organizer's Notes calendar? Currently they are succesfully created in the Reservations database and all, but the organizer is unaware of them despite he's assigned to the reservation.
You do not need to create a session for every user. The important thing is the nnOrganizer = session.createName(" ") which should contain the user. Probably you'll also need to set additional fields like chair or from for the reservation.
If you want to have some entries in the organizers calendar, send them a proper invitation or create a calendar entry in their mailfile.

Intermittent behavior in xpages application: by pressing the button to save, the document is not redirected and is displayed again

I'm having a problem with a new xpages application that was deployed in production for a few months, but has now only been expanded to the entire enterprise now. The problem that did not happen while the application was in production pilot is intermittent and happens when an action executes a current notesxsppdocument save (currentdocument). The symptom is that by pressing the button you save, the document is not redirected and is displayed again. What can be this problem. session timeout, a bug from xpages? The application basically uses the components of the extension library, there is no external component to the xpages. When the problem occurs, if the user closes the document's xpages opens again and then clicks the button again the code runs successfully.
I have a function that stores a file attached to the doc in a repository. I suspect she's the problem. The function uses the file upload component and a button to execute a java agent that stores the file in a repository. The button code below follows. Its function is basically to create the rich text if it does not exist and call the agent that consumes a web service to transfer the file to a repository and erase it from the document.
I asked the user not to use the function for a few days at the time of the service to verify that the problem will persist.
if(validaArquivo())
{
var url=#ReplaceSubstring(context.getUrl(),"openDocument","editDocument")
url += '&tab=dossie' ;
var fieldItem:NotesItem =
currentDocument.getDocument().getFirstItem("arquivos");
if (fieldItem==null){
// create the field as an RTF
//writeToLog("Creating xxxxx field");
var rtItem:NotesRichTextItem =
currentDocument.getDocument().createRichTextItem("arquivos");
currentDocument.save();
}else if (fieldItem.getType()==1280){
//writeToLog("--> Converting xxxxx to RTF");
currentDocument.replaceItemValue("arquivosTEXT",
fieldItem.getText());
fieldItem.remove();
var rtItem:NotesRichTextItem =
currentDocument.getDocument().createRichTextItem("arquivos");
currentDocument.save();
}
var agente:NotesAgent=database.getAgent("(SalvaAnexos)");
agente.runWithDocumentContext(currentDocument.getDocument(true));
context.redirectToPage(url)
}
else
{
document1.removeAllAttachments("arquivos");
}
When users are using the application, rebuild or to change some code on prod environment can cause this.

xpage button to run agent to save document

On an xpage web application the user only has public documents read access.
I would like to find a way for the user to be able to save to a form.
I guess the most secure way is by dooing this with an agent since I read somwhere that giving write access to public documents isn't secure.
Let's say I have 2 fields : firstname and lastname .
Do I bind them to a scoped variable to have acces to them in the agent or is there a better way ?
How do I run the agent on a button click ? is following correct ?
var agent:NotesAgent = database.getAgent("(register)");
How do I give the agent the necessary authority to save the document?
And how do I get my data in my agent ? with for example sessionScope.firstName or is there a better way ?
The eventually smartest way: store that data into another database at all. XPages allows you to write to a different database. If the name shouldn't be visible for other public users, then use depositor as access level
Don't use an agent for saving a document. Use sessionAsSigner instead.
sessionAsSigner allows to run code with the permission of XPage's signer instead of the current user accessing the XPage.
Example:
var db:NotesDatabase = sessionAsSigner.getCurrentDatabase();
var doc:NotesDocument = db.createDocument();
...
doc.save();

Microsoft Dynamics CRM display error returned from plugin through javascript

I am using Microsoft Dynamics CRM (off premise)
Microsoft Dynamics® CRM Online Spring '14 (6.1.0.575)
Via the javascript SDK making a call to create an entity which fires off a plugin. We do our custom validations in the plugin in pre-validation.
Javascript create call example from here -> http://msdn.microsoft.com/en-us/library/gg334427.aspx
//Create the Account
SDK.REST.createRecord(
account,
"Account",
function (account) {
writeMessage("The account named \"" + account.Name + "\" was created with the AccountId : \"" + account.AccountId + "\".");
writeMessage("Retrieving account with the AccountId: \"" + account.AccountId + "\".");
retrieveAccount(account.AccountId)
},
errorHandler
);
And then I can handle the error using that errorHandler function, like this:
function errorHandler(error) {
writeMessage(error.message);
}
However, I am trying to get the error to display in the CRM error dialog box from InvalidPluginExecutionException. It displays it when I create the entity from a form, but when I make the call through javascript I can't seem to get it to display in the CRM error dialog box. I want to keep with the CRM theme, not use alert() in javascript, and have users be able to download the full exception that we are sending back.
Is it possible to call the dlg_error.aspx page in CRM and populate it with our error message? I am grasping at straws right now, anything would help out a lot. Thanks!
If you are using CRM 2013, I would suggest you to use Workflow instead of JavaScript to create record.
Create a new workflow and un-tick the checkbox "Run this workflow in backgroung (recommended)".
Create record from newly created workflow.
Save and publish the record.
Now go the the ribbon and select 'Run Workflow'.
Select the newly created workflow and click 'Add'.
If there is an error thrown by Plugin, It will be displayed in standard CRM Error dialog box which will allow you to download the log file.
You can try to execute a synchronous jQuery ajax method, without catching error and see what happens. Creating a record from jScript you are using RESTful endpoint of CRM service, I am not sure if the error is going to be promoted in the same way. Try to use Fiddler if you would like to try opening error dialog yourself. Using new synchronous workflow feature might also do the trick.

EnsureUser not returning valid User

I am trying to get a user back in SharePoint Client OM using EnsureUser. My code is:
ClientContext clientContext = new ClientContext(siteUrl);
User spUser = clientContext.Web.EnsureUser(user);
Where siteUrl and user are both strings set as appropriate.
The result is spUser is the shell of a User object but all its properties (for example Email, Title, etc.) are not initialized. In VS they are showing {"The property or field has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested."}
What would be causing this? I thought EnsureUser would create the user if it is not already there. I know in Server OM sometimes you need to use "AllowUnsafeUpdates", is there something like that for Client OM?
It is almost a year late, but just in case someone else is searching for the same answer.
After getting a reference to the user object you need to do the following before accessing the properties of the user.
clientContext.Load(spUser);
clientContext.ExecuteQuery();
or if you want to get the email and title only to reduce the pay load.
clientContext.Load(spUser, u => u.Email, u => u.Title);
clientContext.ExecuteQuery();
Basically, it establishs a request to the SharePoint Web and ask for the properties of the spUser. The request will be send when ExecuteQuery() is called.

Resources