Howto: Detect external request with JavaScript

If you have activated Internet Facing Deployment for your CRM system, it could be necessary to detect if a request comes from outside your network or from your internal network.

For example, if you integrate a web application with an IFrame, you have to set different addresses for internal and external access. Or, if the application is only accessible from inside your network, you can show a message that it is not available for external users.

With help of Form Scripting you can detect an external request with little effort. You can make use of the function prependOrgName(”) which adds the organization prefix to the argument, if it is necessary. That means for an external request, it returns always the argument which you have passed.

function IsExternalRequest() 
{
  var ifdTestValue = prependOrgName('');
  var isIFDCall = ifdTestValue == '';
 
  return isIFDCall;
}

Calling IsExternalRequest will return true, if the request comes from an external network range. You could also define this function globally in the form context (see also http://www.stunnware.com/crm2/topic.aspx?id=JS5)

IsExternalRequest = function() 
{
  var ifdTestValue = prependOrgName('');
  var isIFDCall = ifdTestValue == '';
 
  return isIFDCall;
}

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.