Using a function to define javascript objects

Hello, like to ask if the  external parenthises are really necessary?   Like here:
incident.Controller = (...)     //see code block at the end of this question
 I dont think so.   (at least the code works the same for me).
Also, I would also like to know the difference between the two snippet of code below.
The benefit writing the code below in a function (the first snippet below) is to scope things to myCompany.incident by using the "use strict" statement.  Like below. Right?  (i would otherwise write it out as in the snippet beneath
it)
myCompany.incident = (function(incident) {
  "use strict";
  incident.Contracts = {
    onLoad: function() {
      var controller =
              new myCompany.incident.Controller(Xrm);
      controller.load();
  return incident;
}(myCompany.incident || {}));
I would otherwise (if not for "use strict";) write it out like this:
   myCompany.incident = myCompany.incident || {};
   myCompany.incident.Contracts = { onLoad: function() {
         var controller = new myCompany.incident.Controller(Xrm);
         controller.load();
I dont think "use strict;" is the only difference/consquence of the two snippet, which is the reason for this question.
Thanks, p.
/// <reference path="controller.js"/>
/*global myCompany: true*/
myCompany = window.myCompany || {};
myCompany.incident = (function(incident) {
"use strict";
incident.Contracts = {
onLoad: function() {
var controller =
new myCompany.incident.Controller(Xrm);
controller.load();
return incident;
}(myCompany.incident || {}));
Thanks, Paul

There is an application report that give you a listing of your region source and allows you to search the source and gives you links to edit it.
Application Reports>Page Components>Search Region Source
So you shouldn't have to keep it in a separate file.

Similar Messages

  • How to find which all workbook is using Database function ( User Defined)

    Hi All,
    Is it possible to find out which all workbook is using Database function( User Defined).
    Thanks,

    Hi,
    If I had to do this detective work, I would probably do the following:
    1. Activate for a period of time the function, eul5_post_save_document. This function when activated is triggered at the time a workbook is saved. If you look at its columns, it save the worksheet's SQL.
    2. Next, I would parse the EUL5_WORKSHEET_SQL.SQL_SEGMENT column which is a varchar2(4000) column. There are many effective Oracle functions which could aid you in this effort (e.g. instring or perhaps a regular expression function).
    I hope this helps.
    Patrick

  • How can HANA Server Side JavaScript use "Eval" function?

    Hi HANA Experts,
      I use EVAL function to create an object by classname in xsjs file, but it has an Error "Eval is evil". In Client javascript, we can use the Eval function. How can we use "EVAL" function in HANA server side javaScript?  Thanks a lot.

    That looks like the client side JSLint check to me.  Those can be customized or even turned off. If you truly want to use eval.
    >XSJS inherits most of the features of javascript but do not expect all of its features
    Actually that's not exactly accurate.  XSJS is standard ECMA JavaScript (Mozilla SpiderMonkey VM).  It does run in strict mode, however. This isn't a limitation of XSJS but a conscious decision to force the VM into the strict mode - which is really the recommendation for JavaScript anyway.  We also apply JSLint checks as above. Sometimes they are quite restrictive. However they can be customized or even completely turned off at the project level:
    To the point of Eval, there are some excellent articles online.
    http://javascriptweblog.wordpress.com/2010/04/19/how-evil-is-eval/
    coding style - When is JavaScript&amp;#39;s eval() not evil? - Stack Overflow
    JSLint Error Explanations - eval is evil

  • Using a function in a Cursor Definiftion

    Hi all,
    my problem is to define a curson inside a package, using a function already defined in the function.
    My source code is the folowing:
    PROCEDURE TEST
    IS
    CURSOR cursor_test IS
    SELECT ID_CUSTOMER
    FROM CUSTOMER
    WHERE START_VALIDITY_DATE > GET_DATE(DATE_NEW_CUSTOMER, DATE_EXPIRED);
    BEGIN
    END;
    The function Get_date ( a date,b date) is defined in the same package where it is collocated my procedure "Test". The function called "Get date" return a date.
    When I compile, I have an error and I don't understand why.
    Thank'you in advance

    Hi,
    To illustrate APC's point with some simple examples:
    HR%xe> create or replace package test_pkg
      2  as
      3    procedure public_proc;
      4  end test_pkg; 
      5  /
    Package is aangemaakt.
    HR%xe> create or replace package body test_pkg
      2  as
      3    procedure public_proc
      4    is
      5      function private_func
      6      return date
      7      is
      8      begin
      9       return(sysdate);
    10      end private_func;
    11      --
    12      l_count number := 0;
    13      --
    14    begin
    15      select count(*) into l_count
    16      from   employees
    17      where  employees.hire_date < private_func;
    18      --
    19      dbms_output.put_line(l_count||' employees were counted.');
    20      --
    21    end;
    22  end test_pkg; 
    23  /
    Waarschuwing: package-body is aangemaakt met compilatiefouten.
    HR%xe> sho err
    Fouten voor PACKAGE BODY TEST_PKG:
    LINE/COL ERROR
    12/5     PLS-00103: Encountered the symbol "L_COUNT" when expecting one of
             the following:
             begin function package pragma procedure form
    22/5     PLS-00103: Encountered the symbol "TEST_PKG" when expecting one
             of the following:
    HR%xe> create or replace package test_pkg
      2  as
      3  /* commented out the declaration in the specification this time
      4    function private_func
      5    return date;
      6  */ 
      7    procedure public_proc;
      8  end test_pkg; 
      9  /
    Package is aangemaakt.
    HR%xe> create or replace package body test_pkg
      2  as
      3    function private_func
      4    return date
      5    is
      6    begin
      7     return(sysdate);
      8    end;
      9 
    10    procedure public_proc
    11    is
    12      l_count number := 0;
    13    begin
    14      select count(*) into l_count
    15      from   employees
    16      where  employees.hire_date < private_func;
    17      --
    18      dbms_output.put_line(l_count||' employees were counted.');
    19      --
    20    end;
    21  end test_pkg; 
    22  /
    Waarschuwing: package-body is aangemaakt met compilatiefouten.
    HR%xe> sho err
    Fouten voor PACKAGE BODY TEST_PKG:
    LINE/COL ERROR
    14/5     PL/SQL: SQL Statement ignored
    16/34    PL/SQL: ORA-00904: "PRIVATE_FUNC": invalid identifier
    16/34    PLS-00231: function 'PRIVATE_FUNC' may not be used in SQL
    HR%xe> create or replace package test_pkg
      2  as
      3  
      4    function private_func
      5    return date;
      6   
      7    procedure public_proc;
      8  end test_pkg; 
      9  /
    Package is aangemaakt.
    HR%xe> create or replace package body test_pkg
      2  as
      3    function private_func
      4    return date
      5    is
      6    begin
      7     return(sysdate);
      8    end;
      9 
    10    procedure public_proc
    11    is
    12      l_count number := 0;
    13    begin
    14      select count(*) into l_count
    15      from   employees
    16      where  employees.hire_date < private_func;
    17      --
    18      dbms_output.put_line(l_count||' employees were counted.');
    19      --
    20    end;
    21  end test_pkg; 
    22  /
    Package-body is aangemaakt.
    HR%xe> exec test_pkg.public_proc
    107 employees were counted.
    PL/SQL-procedure is geslaagd.Once you declare your function in your package specification as well, you can use your function in your procedure.
    http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14251/adfns_packages.htm#sthref823

  • How to use goto function?

    how to use goto function in indesign javascript??
    my script starts with chekcing whether input files are present or not.. if any of the input files r not present, i want to skip the function n terminate the functioning with displaying the message tht file doesnt exisit.... i was wondering to use goto function for tht...so how to use it? or is there any other alternative to that??

    goto is generally frowned on by programmers.
    The only legitimate use of goto is when you need to escape a nested loop.
    If you need to skip part of a routine, use break, or simply return from the current function.
    The pattern commonly used by the SDK looks like this:
    do
         if(condition1 == false)
              break;
         if(condition2 == false)
              break;
         if(condition3 == false)
              break;
         doSomethingReallyCool();
    }while(false);
    "break" jumps to the end of the do/while loop which always exits when you reach the end of it (while(false))
    Harbs

  • How to upload a document with values related to document properties in to document set at same time using Javascript object model

    Hi,
          Problem Description: Need to upload a document with values related to document properties using custom form in to document set using JavaScript Object Model.
        Kindly let me know any solutions.
    Thanks
    Razvi444

    The following code shows how to use REST/Ajax to upload a document to a document set.
    function uploadToDocumentSet(filename, content) {
    appweburl = decodeURIComponent(getQueryStringParameter('SPAppWebUrl'));
    hostweburl = decodeURIComponent(getQueryStringParameter('SPHostUrl'));
    var restSource = appweburl +
    "/_api/SP.AppContextSite(@target)/web/GetFolderByServerRelativeUrl('/restdocuments/testds')/files/add(url='" + filename + "',overwrite=true)?@target='" + hostweburl + "'";
    var dfd = $.Deferred();
    $.ajax(
    'url': restSource,
    'method': 'POST',
    'data': content,
    processData: false,
    timeout:1000000,
    'headers': {
    'accept': 'application/json;odata=verbose',
    'X-RequestDigest': $('#__REQUESTDIGEST').val(),
    "content-length": content.byteLength
    'success': function (data) {
    var d = data;
    dfd.resolve(d);
    'error': function (err,textStatus,errorThrown) {
    dfd.reject(err);
    return dfd;
    Then when this code returns you can use the following to update the metadata of the new document.
    function updateMetadataNoVersion(fileUrl) {
    appweburl = decodeURIComponent(getQueryStringParameter('SPAppWebUrl'));
    hostweburl = decodeURIComponent(getQueryStringParameter('SPHostUrl'));
    var restSource = appweburl +
    "/_api/SP.AppContextSite(@target)/web/GetFolderByServerRelativeUrl('/restdocuments/testds')/files/getbyurl(url='" + fileUrl + "')/listitemallfields/validateupdatelistitem?@target='" + hostweburl + "'";
    var dfd = $.Deferred();
    $.ajax(
    'url': restSource,
    'method': 'POST',
    'data': JSON.stringify({
    'formValues': [
    '__metadata': { 'type': 'SP.ListItemFormUpdateValue' },
    'FieldName': 'Title',
    'FieldValue': 'My Title2'
    'bNewDocumentUpdate': true,
    'checkInComment': ''
    'headers': {
    'accept': 'application/json;odata=verbose',
    'content-type': 'application/json;odata=verbose',
    'X-RequestDigest': $('#__REQUESTDIGEST').val()
    'success': function (data) {
    var d = data;
    dfd.resolve(d);
    'error': function (err) {
    dfd.reject(err);
    return dfd;
    Blog | SharePoint Field Notes Dev Tools |
    SPFastDeploy | SPRemoteAPIExplorer

  • Unable to update rating (rating column) on host document using JavaScript Object Model API inside sharepoint hosted apps

    Hi Everyone,
    We are developing SharePoint hosted apps for Office 365, for that we are going
    to implement document rating functionality inside Sharepoint app. The host web contain document library (“Documents”) and from apps we need to rate each document. The rating functionality working fine with CQWP in team site  using
    JavaScript Object Model API.
    But the same code is not working inside apps and giving error:-
    If we are using app context than error will be:-
    "List does not exist.
    The page you selected contains a list that does not exist.  It may have been deleted by another user."
    And for Host context than error will be:-
    "Unexpected response data from server."
    Please help on this
    Please see below code..
    'use strict';
    var web, list, listItems, hostUrl, videoId, output = "";
    var videoLibrary = "Documents";
    var context, currentContext;
    var lists, listID;
    var list, parentContext;
    var scriptbase;
    (function () {
        // This code runs when the DOM is ready and creates a context object which is 
        // needed to use the SharePoint object model
        $(document).ready(function () {
            hostUrl = decodeURIComponent(getQueryStringParameter("SPHostUrl"));
            context = SP.ClientContext.get_current();      
            SP.SOD.executeFunc('sp.js', 'SP.ClientContext', sharePointReady);
        function sharePointReady() {
            scriptbase = hostUrl + "/_layouts/15/";
            // Load the js files and continue to the successHandler
            $.getScript(scriptbase + "SP.Runtime.js", function () {
                $.getScript(scriptbase + "SP.js", function () {
                    $.getScript(scriptbase + "SP.Core.js", function () {
                        $.getScript(scriptbase + "reputation.js", function () {
                            $.getScript(scriptbase + "sp.requestexecutor.js", execCrossDomainRequest);
        //Query list from hostweb
        function execCrossDomainRequest() {       
            //Load the list from hostweb
            parentContext = new SP.AppContextSite(context, hostUrl);
            web = parentContext.get_web();
            list = web.get_lists().getByTitle(videoLibrary);
            context.load(list, 'Title', 'Id');
            var camlQuery = new SP.CamlQuery();
            camlQuery.set_viewXml('<View><Query><OrderBy><FieldRef Name="Modified" Ascending="FALSE"/></OrderBy></Query><RowLimit>1</RowLimit></View>');
            listItems = list.getItems(camlQuery);        
            context.load(listItems);
            context.executeQueryAsync(onQuerySucceeded, onQueryFailed);
        //Process the image library
        function onQuerySucceeded() {       
            var lstID = list.get_id();
            var ctx = new SP.ClientContext(hostUrl);       
            var ratingValue = 4;
            EnsureScriptFunc('reputation.js', 'Microsoft.Office.Server.ReputationModel.Reputation', function() {      
            Microsoft.Office.Server.ReputationModel.Reputation.setRating(ctx, lstID, 1, ratingValue);       
            ctx.executeQueryAsync(RatingSuccess, RatingFailure);
        function onQueryFailed(sender, args) {
            alert('Failed' + args.get_message());
        function failed(sender, args) {
            alert("failed because:" + args.get_message());
        function RatingSuccess() {
            alert('rating set');
            //displaystar();
        function RatingFailure(sender, args) {
            alert('Rating failed : : ' + args.get_message());
        //Gets the query string paramter
        function getQueryStringParameter(paramToRetrieve) {
            var params;
            params = document.URL.split("?")[1].split("&");
            for (var i = 0; i < params.length; i = i + 1) {
                var singleParam = params[i].split("=");
                if (singleParam[0] == paramToRetrieve) return singleParam[1];
    Thanks & Regards
    Sanjay 
    Thank you in advance! :-)
          

    Hi,
    According to your post, my understanding is that you want to update list column in SharePoint hosted apps using JavaScript Client Object Model.
    Based on the error message, it seems not retrieve the list object in context. I suggest you debug the code step by step using Internet Explorer Developer Tools to
    find the problem.
    Here are some demos about using JavaScript Client Object Model in SharePoint hosted app:
    http://blogs.msdn.com/b/officeapps/archive/2012/09/04/using-the-javascript-object-model-jsom-in-apps-for-sharepoint.aspx
    http://sharepoint.stackexchange.com/questions/55334/how-to-access-list-in-sharepoint-hosted-app
    http://www.dotnetcurry.com/showarticle.aspx?ID=1028
    Best regards
    Zhengyu Guo
    TechNet Community Support

  • AJAX retrieval using Javascript Object Notation (JSON) - How To

    I have written up a how-to on my blog, explaining the steps involved to implement AJAX functionality using JSON for data transmission. It uses a simple example where the user makes a selection from a select list and 2 values are returned from the database into page items. I found it pretty simple to implement.
    http://anthonyrayner.blogspot.com/2007/06/ajax-retrieval-using-javascript-object.html
    Hope you like it, feedback welcome!!
    Anthony.

    Duplicate post.
    Yann C.
    France

  • After Effect CC: Custom JavaScript functions of a flashplayer object return no value

    Hi
    With AfterEffects CC scripting it looks like custom JavaScript functions of a flashplayer object return no value when invoked from ActionScript code
    This can be seen in the sample script shipped with ExtendScript Toolkit named ActionScriptDemo.jsx:
    Create a flashplayer object in a JSX file with a custom getJavaScriptNumber function:
    var flashPlayer = flashPalette.add("flashplayer", cBounds);
    flashPlayer.getJavaScriptNumber = function() {
              return 12345;
    Invoke the custom getJavaScriptNumber function from ActionScript code of an .MXML file:
    public function requestJavaScriptNumber():void{
              var res:int = ExternalInterface.call("getJavaScriptNumber");
              estkNumber = res;
    The ExternalInterface.call("getJavaScriptNumber") call return no value
    Any idea or a suggested workaround??
    Thanks, Erez.

    I wonder if this was intentional on Adobe's part.  It seems rather odd that it just "broke" with the upgrade to CC.
    I was thinking of a way to display a "web page" within an ExtendScript dialog / window, and thought that I could use Flash / ActionScript to do just that and then display that within the dialog.  It seems, now, that it is just a bad idea because the API for ExternalInterface is broken--I would need two-way communication between the Flash object presenting the webpage and the ExtendScript ScriptUI Panel.
    Is there a workaround for this?
    Thanks,
    Arie

  • How to use the index method for pathpoints object in illustrator through javascripts

    hii...
    am using Illustrator CS2 using javascripts...
    how to use the index method for pathpoints object in illustrator through javascripts..

    Hi, what are you trying to do with path points?
    CarlosCanto

  • How do I define javascript global variables to use across windows

    I have a number of web pages. I have javascript for each page. I need to share some data across the web pages. How do I define javascript variables that can be accessed from multiple web pages?

    Use SugarSync.

  • How to use destination function for javascript

    Hi,
    I used javascript:var a = window.open('OA.jsp?page=/oracle/apps/cdar/admin/brandupload/webui/SupportPG&retainAM=Y&OARF=printable', 'a','height=500,width=900,menubar=yes,toolbar=yes,location=yes'); a.focus(); in destination URL property, it can work to popup another window.
    But I want to setup a Oracle function for this javascript, and use Destination FUNC property on the button to popup window. But it can not work after I setup a SSWA jsp function with WEB HTML.
    Could some one help this?
    Thanks,
    Eileen

    Eileen,
    How are you adding the OA function ? I have also tried destination url property but not the destination function.Probably you should do sth like this :
    In ProcessRequest :-
    <OABean> <var name> = (<OABean>)webBean.findChildRecursive("<Bean Id>");
    <var name>.setOnClick("javascript:window.open ('OA.jsp?OAFunc=<funcName>','new','height=550,width=850,status=yes,scrollbars=yes,toolbar=no,menubar=no,location=no' );
    OABean is the bean on click of which the page should open like a hyperlink or sth like that.
    Hope this helps.

  • Can we define the objects (varibales, etc) in the OLAP Worksheet and use it

    Hi,
    I am using AWM 11g ( AWM 11.2.0.3 ). I am trying to build cube for financial data. I tried to define variables, relations in the express backend (rather OLAP worksheet) for refering it into OLAP expressions 9frontend measure. However, whenever I define some object and save it (upd command). I am not finding the same object at the next loging. Is there any way I can do this?
    Thanks,
    Sam

    You can define objects using the OLAP Worksheet. Make sure that you run "commit" after the "update".

  • Wich function (class) could I use to create one pixel high object (frame)?

    Hi guys, I need a pointer on a certatin line on the graphic screen. And I want it to be written in Java. I know how to make it to be "always on top" now, but AFAIK every applet or application is to be shown in a bordered window saying it is a Java object for security reasons. As I want it to be one pixel high, I apparently need to get rid of the frame border. Supposedly I have to switch off the security, but it's OK for me.
    Wich function (class) do I use to create one pixel high object?
    And one more thing. How do I generally show a graphic object of nonrectangular shape out of the bordered frame? Is there a way to do it without creating an transparent rectangular window/frame?

    I didn't quite know what you mean, but how's this?
    public class MySinglePixelWindow extends JWindow {
       public MySinglePixelWindow() {
          super();
          setSize(1,1);
          setLocation(0,0);
       public void paint(Graphics g) {
          super.paint(g);
          g.fillRect(0,0,1,1);
    }Transparent Window:
    public class MyTransparentWindow extends JWindow {
       java.awt.Robot robot;
       BufferedImage screen;
       public MyTransparentWindow() {
          super();
          try {
             robot = new Robot();
          } catch(Exception e) {}
       public void show() {
          image = robot.createScreenCapture(getBounds());
          super.show();
       public void paint(Graphics g) {
          super.paint(g);
          Graphics2D g2 = (Graphics2D)g;
          g.setComposite(AlphaComposite.newInstance(AlphaComposite.SRC_OVER,0.8));
          g.drawImage(image,0,0,this);
    }Puh!
    You can't move this window though...
    Nille

  • Use function from external Javascript file

    Hi All,
    Is it possible to use function from other javascript file. If possible then please post some example.
    Shonky

    As Harbs mentioned, you can use doScript().
    Maybe you can do something like this:
    First I created simple function in separate file and exported it JSXBIN
    function myAlert(myString){
        alert(myString);
    Then, I copied contents of that JSXBIN and put it into variable
    var securedFUNCTION = app.doScript("@JSXBIN@ES@[email protected]AffABC40BhAB0AzHjNjZiBjMjFjSjUDAC0EzAEByB");
    or
    var securedFUNC = eval("@JSXBIN@ES@[email protected]AffABC40BhAB0AzHjNjZiBjMjFjSjUDAC0EzAEByB");
    And simply called function
    myAlert('My test String');
    Also, you can use include external script with #include to call JSXBIN, but you need to wrap contents of JSXBIN file into doScript or eval().
    tomaxxi
    http://indisnip.wordpress.com/

Maybe you are looking for

  • Regarding MIRO baseline date in payment tab

    Hi All, T-code: MIRO Input invoice date: 'xxxxxxxxxx', posting date:  'xxxxxxxxxx', PO# 'xxxxxxxxxx' and then press ENTER After pressing ENTER, can you do some coding to the user exit or field exit whatever in order to populate the GR date (i.e.  'xx

  • Af:table rollup row background color change

    Hi All i got below sql view object SELECT DEPARTMENT_ID,JOB_ID,COUNT(*) FROM EMPLOYEES GROUP BY DEPARTMENT_ID,ROLLUP(JOB_ID) By using this i will get each department_id, jobid's and total employes count in each department and i will get rollup for ea

  • Ipod touch syncing in iTunes

    I sync my iPod Touch (1st Gen) in iTunes and when it's disconnected all of the content is gone. This just started recently. I did a restore and reloaded all of the contents but everything disappeared again after I synced. The apps remain but the musi

  • Add a button to MSS Compensation Planning screen

    Hi Gurus, I have a requirement from my client to add a button in Compensation Planning screen to Download the list. However, I couldn't find a configuration in IMG to add it. The Compensation screen is a WDJ and we do not have Java expert in our team

  • How do you unlock a apple ipod

    hello , please could you give me some advise to unlock a apple ipod