Save record embedded in iframe - dynamics-crm-2011

Scenario
CRM2011, rollup 13
Account form with iframe, that displays contact form. Requirement is that when user press "save" button on account form, contact in iframe should be also saved.
OnSave event code
var iframeXrmPage = Xrm.Page.getControl("IFRAME_contact").getObject().contentWindow.Xrm.Page;
iframeXrmPage.data.entity.save(); //error: Unable to get property 'entity' of undefined or null reference
I can get Xrm object of iframe, but it has data and ui members set to null.
Is there any way to call save() in iframe using Xrm.Page? Are there any alternatives?

Use below code:
var iframeXrmPage = Xrm.Page.getControl("IFRAME_contact").getObject().contentWindow.contentIFrame.Xrm.Page;

Related

Alert in view record for Netsuite

I have been trying to get a alert in Netsuite for view mode but can't get it for customer record.
Though when I tried to get the alert for the edit record then I got it but I want it for view.
I tried client script, user event script and also workflow. But all support only for edit. Can I get the alert by any means for the view record option.
Thanks
Gladiator
One workaround that I've done is to add a custom field of type 'Inline HTML' to the customer form. Then during the beforeLoad event you can check if type == 'view' and update the custom field's value with the HTML that is needed to display the alert.
Basically form.setScript used to work with SS1 but there was no (not hacked) API access to Netsuite's alerts
SS2.0 gives nice access to the alert system but it doesn't load in view mode unless you take a supported action (clicking a button)
See this answer for a sample with SS2 that loads your script and shows an integrated alert.
SS2.0 Display Message on Record
Thanks Mike, Michoel and Bknights.
Here is the solution to the problem.
Create an inline html field on the customer form.
Since the field does not store value nlapiSetFieldValue for before load function works absolutely fine.
Below is the snippet of the working code.
function before_load(type)
{
if (type == 'view')
{
var pass_value = "<html><body><script type='text/javascript'>window.alert('Hello World!!!')</script></body></html>";
nlapiSetFieldValue("custentity25", pass_value); //custentity25 is the id of Inline HTML field we created
}
}
Note : The "" used should be different then the one used in the HTML code which is ''. If same are used then there will be an error.
You need to use a User Event Script, and in the before load event, set a Client Script via form.setScript(). In your "injected" Client Script, you can display the alert.

Netsuite: How to insert an iframe on post call

I have written a suitelet which has two parts - GET and POST.
In GET method I have a dropdown and a submit button.
In POST method, I have 5 text fields which display the data based on value fetched from dropdown in GET.
I want to call an iframe on submit button click. iframe will show POST method logic. In short, I don't want to navigate to new page on submit, but to make the whole thing work on a single page.
MY CODE
function init(request, response)
{
if(request.getMethod() == 'GET')
{
//... some code for dropdown and submit
//code for iframe
var context = nlapiGetContext();
var url = 'https://**url-of-post-method-results**.com';
var title = context.getSetting('SCRIPT', 'custscript_suitelet_title')
var content = '<iframe width=960px height=100% style="height:640px;" src=' + url + '></iframe>'
var newField = form.addField ('content', 'inlinehtml', title);
form.addField('extra', 'inlinehtml', '')
form.setTitle (title);
newField.setLayoutType('outsidebelow');
newField.setDefaultValue (content);
form.addSubmitButton('Submit');
response.writePage(form);
}
}
I referred to Marty Zigman's tutorial on embedding iframe. But I'. confused where to embed the iframe, in GET or POST?
To the best of my knowledge, NetSuite has no built in way via their API to avoid a page refresh in a case like this. Clicking the submit button, will by default, submit the form via a post method synchronously. You need to interrupt the click() event method via jQuery on NetSuite's default form submit button using client side code. You would then send the post yourself using jQuery, and on a response, show the information you would like, again via jQuery, by updating the iframe src url.
I apologize I do not have currently have access to an account to be able to give you the appropriate JavaScript. I would be cautious of breakage though since you will need to hack into the NetSuite UI a bit to make this work.

CRM2011: Open crm lookup from another application with customview

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.

Unable to get document page name for

I have a view that has XPage Associated with document form set.
The form property has the xpage associated with the document.
If I click on the link in the view the proper correct xpage is displayed as expected.
But if I close the browser, and paste the URL to the document into the browser, I get the error, Unable to get document page name for (and the unid). As long as I remain logged in the url will work without error or if I set anonymous to Reader the url will continue to work. But if I close the browser where I would be prompted to login then I get the error but I get the error before being prompted to log in.
The url for assocated forms looks a little different than when the view is used to display the xpage.
myserver/mydb.nsf/$$OpenDominoDocument.xsp?documentId=12B571F2B03E3764852573690041E273&action=openDocument
The view has various types of forms so I need to associate the form with the xpage or I suppose I can compute the xpage for the form. But any idea what would be causing this issue?
If you are opening a document from a view, the associated form could be overriden by a form formula of the view. When opening the document directly with $$OpenDominoDocument.xsp the original form stored in the document is used instead.
The form can be associated with a XPage in different ways:
For XPiNC there is a field $XPagesAltClient in the form
For web access there is a field $XPagesAlt in the form
There is a entry in the xsp.properties file.
For example this entry...
xsp.domino.form.xpage.foo=bar
...will open a document with the value foo in the Form field with the XPage bar.xsp.
Hope this helps
Sven

How to access separate yui object from one another

In "Start Workflow" page, "Start Workflow" form is generated from Form-Engine.
I want to disable "Start Workflow" button when submitting form. When
callback, I want to enable this button.
In start-workflow.js, I can get this button by using
var submitButton = Dom.get(this.generateId + "-form-submit-button");
submitButton.setAttribute("disabled", "disabled");
But adding attribute "disabled" does not work in IE8 as button can even click. But it works in mozilla. But by using yui disabled,
this.submitElements[0].set("disabled", true); can be work.
The problem is that how can I access Alfresco.FormUI(form.js) from Alfresco.component.StartWorkflow(start-workflow.js). Since they are separate yui object, I do not know how to access from one another.
If you know, let me share your knowledge and experience.
If the other component extends Alfresco.component.Base then it should have registered its presence on the page when it was instantiated.
You can then use Alfresco.util.ComponentManager (docs) to retrieve the instance you want, e.g. if it is the only instance on the page,
var otherCmpt = Alfresco.util.ComponentManager.findFirst(p_sName)
where p_sName is the full name of the class as a String value, e.g. "Alfresco.FormUI".

Resources