Schlagwort-Archive: Form Scripting

Howto: Get label for an attribute with JavaScript

If you have to retrieve the label of an attribute in a form script, you have two options. The first one, is of course not supported, but quick and easy to implement.

function GetFieldLabel(fieldname)
{
  var field = crmForm.all[fieldname+ '_c'];
 
  if (field != null){
    return field.firstChild.firstChild.nodeValue;
  }
  else {
    return '';
  }
}
 
alert(GetFieldLabel('subject'));

The other option is, to retrieve the label for the user language from the crm service. I will cover this in another article.

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;
}