I couldn't make a request to a remote server using JavaScript in the onload function due to access is denied insanity. So, just to make CRM obey, I set up an IFRAME and connect that to a HTML page running my JavaScript. Now, provided that I get some values inside the script (run in an IFRAME) how can I communicate them to a method in the holding parent?
Not quite sure how to explain it more detailed so please feel free to ask.
The access is denied is the Same Origin Policy. You're going to run into the same problem from the IFRAME unless you're serving the page or just the script src from the same server you're subsequently trying to make the AJAX request to.
Assuming you are doing the latter then you just need to make sure you have unchecked the "Restrict cross-frame scripting" option on the IFRAME you added to the CRM form. From the IFRAME you will now have access to your function that you've defined at global scope on the parent CRM form via window.parent.yourfunctionNameHere(xyz).
postMessage sounds like it might fit.
window.postMessage, when called, causes a MessageEvent to be dispatched at the target window when any pending script that must be executed completes (e.g. remaining event handlers if window.postMessage is called from an event handler, previously-set pending timeouts, etc.). The MessageEvent has the type message, a data property which is set to the string value of the first argument provided to window.postMessage, an origin property corresponding to the origin of the main document in the window calling window.postMessage at the time window.postMessage was called, and a source property which is the window from which window.postMessage is called.
To use window.postMessage, an event listener must be attached:
// Internet Explorer
window.attachEvent('onmessage',receiveMessage);
// Opera/Mozilla/Webkit
window.addEventListener("message", receiveMessage, false);
And a receiveMessage function must be declared:
function receiveMessage(event) {
// do something with event.data;
}
The off-site iframe must also send events properly via postMessage:
<script>window.parent.postMessage('foo','*')</script>
Any window may access this method on any other window, at any time, regardless of the location of the document in the window, to send it a message. Consequently, any event listener used to receive messages must first check the identity of the sender of the message, using the origin and possibly source properties. This cannot be understated: Failure to check the origin and possibly source properties enables cross-site scripting attacks.
Source: https://developer.mozilla.org/en/DOM/window.postMessage
Recently I had the joy of connecting to a web service and retrieve some data. When that’s been achieved, I found myself sitting on the said data not exactly knowing where to put it.
To make the long story short, I used the following source code.
parent.window.Xrm.Page.data.entity.attributes
.get("new_Konrad").setValue("Viltersten");
Notable is the fact that in order to communicate with the parent form, the HTML file (where my JavaScript resided), needed to be placed as a web resource within the CRM structure. By other words, just by pointing to an external “http://some.where/some.thing” we can consume a service but won’t be able to convey the obtained information up the CRM server, at least not when developing a solution for the on-line version.
Related
I'm using Blueprism and I have to create a robot for a web application. So far I've had all of my subpages spied in one object, but now I must split that object into 5 different objects, each object for one subpage for example :
Now I got this : Web App - Object and I must split it into
Web App - Login Page
Web App - Main Page
Web App - Settings Page etc.
Everything worked when I had just one object but now it's not.
I spied elements again for my new objects in my application modeler.
Also I tried the "Sharable option" and of course published all of my pages.
For example my Web App - Main Page action cannot be used by my Settings Page. I can choose it from the list but then I get this error :
Internal : Failed To perform Step 1 In Navigate Stage 'Click' on page 'click' - Not Connected
What should I do and what should I write in application modeler when I'm asked for the URL of my start page? I've tried the main url for example web.com, my subpages url : web.com/main and also I tried to leave it blank.
Please help me to solve this problem
When splitting your functionality across multiple objects, it's important to note how Blue Prism handles connections ("attachments") to individual applications.
When a Business Object is leveraged to Launch a business application, the attachment to the application itself is (normally) handled in the background by Blue Prism. When another business object is created, the attachment isn't handed off to the secondary object(s). This is clearly laid out in the Blue Prism Object Design Guide document, section "4.2.4. Attaching":
An object must be attached to the application before it can be used
to automate it. When an object launches an application, it is
automatically attached to that application. Therefore, the ‘Basic
Actions’ object does not require an ‘Attach’ action. The remaining
objects that wish to work with an application that is already launch
must first attach to the application.
The solution to this object design paradigm is to include a non-published "Attach" function in each of the secondary objects that's called at the start of each of the secondary object's actions. From the aforementioned guide:
If an object attempts to attach to an application when it is already
attached, an error will result. Therefore, when building an ‘Attach’
action, it is best practice to first detect if the object is already
attached to the application. A typical ‘Attach’ action may look like
this
By using the approach above, every other action within the object can call the ‘Attach’ page as is its first stage to
ensure the action is ready to work with the application e.g.
If you are already launched the application then no need to keep url to rest of the Objects , just in application modeler u check the checkbox for application is already running, after that in each and every page attach the application and in the attach page keep the web page(all the navigating pages) names in the collection and passing it as a webtitle parameter to the attach stage
This works fine.
i am using guard as my custom authenticator, i need to send an email inside the authenticator, using the service fos_user.mailer that i injected which has arguments amoung which there is twig because it renders the message it needs to send, now the problem i have is that i get an error "Circular reference detected for service ..." which says that my authenticator calls the mailer which calls the twig which again calls the authorization checker (my authenticator) resulting in an endless loop,
do you have any solutions for this
The quick and dirty workaround is to inject the container to your authenticator and get the mailer service when you need it. It's dirty, because it hides your dependencies.
But why do you need to send an email in your authenticator? Can you use one of symfony's authentication-related events instead? (See the AuthenticationEvents and SecurityEvents classes). If that's not enough, you can also create your own event and listen to that in a different service, that's responsible for sending that mail.
Using the browser client, how can I set the sounds.disconnect() on every call? Is there a way to access the device singleton to modify that setting? I know I can access when I get the device.ready callback, but I want to modify the setting on every call.
I received a helpful reply back from Twilio support:
--
That parameter will be instantiated in Twilio.Device either True or False once the web page loads, so to change it, I believe you would necessarily need to also reload the page.
This would create another control layer in effect, that isn't provided out of the box by Twilio: you'd need to build a web page to change the variable that determines sounds.outgoing(), and then trigger the page to reload.
Another option would be simply create a second Client instance running on a separate tab, and have both instances use the same outbound caller ID. That might be easier.
--
In my scenario I'll need to find a different approach, and will look in to disabling the Twilio sounds and using my own.
Originally posted this question here:
https://groups.google.com/a/chromium.org/d/msg/chromium-extensions/wbSpXvnO10A/nov36skmnQ0J
My extension has an optional feature that interacts with the user's gmail tab. We don't want to mention mail.google.com domains at all in the permission confirmation that the user sees when first installing the extension. So I moved that entry out of the manifest's permissions block and into the optional_permissions block. We also needed to use a content script tied to mail.google.com, but defining this in the manifest causes the 'mail.google.com' permission warning that is sppoking some users.
I've tried removing the content_script manifest block and using Programmatic Injection instead as describe here. http://developer.chrome.com/extensions/content_scripts.html#pi
However scripts injected that way are not content scripts and don't have access to the needed APIs (chrome.tabs, etc)
Is there some way to get the best of both worlds: use optional_permission, AND get the content scripts added to a matching URL, but only if the user has approved the optional permission?
It seems like you could create a background page, and call chrome.tabs.query against your optional origin to get a list of tabs that match that host. You can then call programmatic injection to the content script (chrome.tabs.executeScript). None of these require the "tabs" permission (many "tabs" functions don't require any special permission, and it intelligently lets you query for tabs whose origins match your optional permission)
You could call this every second or so to see if there are any new tabs for which you haven't yet called executeScript.
It would be nice if this were edge-triggered. See https://code.google.com/p/chromium/issues/detail?id=264704
You can actually get it to be mostly edge triggered by using chrome.tabs.onUpdated.addListener and simply trying to inject every time that is triggered (which will be every time a page loads in any tab, regardless of whether you have permission or not). You'll get a lot of errors in the background script's console when you don't have permission. It will be important to have your content script set a variable like _I_already_executed=true and check for its existence so that you're not injecting multiple times (this event gets triggered several times for each page load)
Now there's the contentScripts.register() API, which lets you programmatically register content scripts.
browser.contentScripts.register({
matches: ['https://mail.google.com/*'],
js: [{file: 'content.js'}]
});
This API is only available in Firefox but there's a Chrome polyfill you can use. The new scripts will work exactly like your regular content scripts in manifest.json.
For a more comprehensive solution you could look into my webext-domain-permission-toggle and webext-dynamic-content-scripts modules, which don't apply directly to your use case but can be helpful to who wants to drop the <all_urls> permission and inject content scripts on demand.
I have a SharePoint site page with a document library web part on it, once a document is uploaded to this library, some of the library fields need to be updated according to a parameter of the page url.
I tried doing this with Event Receiver binding on the library, only to find that I cannot get the page url, or rather the parameter, in the Event Receiver. Then Session occurred to my mind, but after asking around and searching a lot, I can only get HttpContext in itemAdding but not itemAdded, what's worse, HttpContext.Current.Session always give me nulll and I'm sure I have put some value into session earlier in somewhere else.
Can someone shed some light on this, any help or advise is deeply appreciated.
SharePoint allows synchronous and asynchronous event receivers. You can get access to HttpContext and SPContext in synchronous receiver, as it runs in worker thread. Read more for accessing HttpContext and how to bind synchronous receiver programmatically.
It's a bit late but for reference I've just seen solution on this page.
It leverages custom control in master page and stores the information into HttpRuntime.Cache. Then access it from within the synchronous event.
The event receiver is not called in the page context. Therefor you can't access the page information. The only approach to this that I can see is to write custom code that prefills the values of the page before you save the item.