Extendscript (JS): How to guard undefined object properties?

Just picked up this Extendscript for a quick utility function. I can't seem to use any of the "usual" Javascript logic contstructs to test for undefined object properties.
Example:
typeof(app.activeDocument) === "undefined"
This is an *error* in Extendscript (Error 1302: No such element). I don't believe it should be, but if I'm supposed to do something different in Extendscript I am all ears.
Thank you
Edit: Now posted to the correct forum.

You could fix up something like:
var nicer_obj = function (obj) {
    var new_obj = {}
    for (key in obj) {
        if (obj.hasOwnProperty(key)) {
            try { new_obj[key] = obj[key]; } catch (err) {}
    return new_obj;
typeof nicer_obj(app).activeDocument; // 'undefined' or 'object'
For what it’s worth, I also think it’s really stupid and annoying that the built-in objects don’t behave at all like you’d expect typical ECMAScript objects to behave. Browsers used to have similar quirks (which is why everyone just uses jQuery), but many of those have been worked out by now.

Similar Messages

  • OLE object -Properties/Parameters of a method

    HI,
      Sample code,
    CREATE OBJECT application 'excel.application'.
    SET PROPERTY OF application 'visible' = '1'.
    CALL METHOD OF application 'Workbooks' = workbook.
    CALL METHOD OF workbook 'Add'.
    CALL METHOD OF sheet 'Cells' = cells EXPORTING #1 = index.
    GET PROPERTY OF cells 'Font' = gs_font .
    SET PROPERTY OF gs_font  'Bold' = 1.
    SET PROPERTY OF gs_font 'ColorIndex' = 5.
    SET PROPERTY OF cells 'Value' = 'Server name'.
    In this sample code , properties Visible, Bold, Colorindex, Value are set to some values.
    How to find these properties ?
    In which DB Table they are stored ?
    How to get all the properties/parameters of a method ?
    All are concerned with ABAP OLE Objects .
    Pls help regarding this .

    Hi
    Try make in Excel a macro, which do what you need  and analyse than the code of the macro.
    It is very helpfull to find the properites.
    JS

  • How to dynamically changes items properties

    How to dynamically changes items properties likes position order in tabular view, width, prompt

    Many object properties can be set programmatically at runtime. For example, each window object has a Visible property that can be set to either Yes or No to show and hide the window. At runtime, you can call the built-in procedure SET_WINDOW_PROPERTY to show or hide the window dynamically, as shown here:
    Set_Window_Property('my_window',VISIBLE, PROPERTY_ON);
    The following built-in procedures are available for setting object properties at runtime:
    -     SET_BLOCK_PROPERTY
    -     SET_CANVAS_PROPERTY
    -     SET_FORM_PROPERTY
    -     SET_ITEM_PROPERTY
    -     SET_LOV_PROPERTY
    -     SET_MENU_ITEM_PROPERTY
    -     SET_PARAMETER_ATTR
    -     SET_RADIO_BUTTON_PROPERTY
    -     SET_RECORD_PROPERTY
    -     SET_RELATION_PROPERTY
    -     SET_VIEW_PROPERTY
    -     SET_WINDOW_PROPERTY
    The built-in procedure SET_ITEM_PROPERTY can be used to set the properties of any type of item, including buttons, text items, check boxes, radio groups, etc.
    Note: Radio group items include individual radio buttons; use SET_ITEM_PROPERTY to set the properties of the radio group, and SET_RADIO_BUTTON_PROPERTY to set the properties of the individual buttons in the group.
    Each built-in SET procedure has a corresponding GET function that allows you to programmatically determine the current setting of an object's properties. The following example uses GET_WINDOW_PROPERTY to determine if a window is currently hidden (VISIBLE = FALSE). If the window is hidden, SET_WINDOW_PROPERTY is called to show the window.
    If Get_Window_Property('my_window',VISIBLE) = 'FALSE' THEN
    Set_Window_Property('my_window',VISIBLE,PROPERTY_ON);
    To determine if a particular property can be set programmatically, refer to the property descriptions in online Help.

  • How to compare two Objects !!!!

    Hi All,
    I know that this question has been asked 100 times till now. But trust me I have checked all of them but couldn`t find answer. Here is my question:
    I have an objecs. In that object I am setting (Id,Name,DOJ). Now I want to check whether the object I am trying to save in database already exists or not. If exists then I need to check whether all the setters are same for the two objects. Now can anyone tell me ,how to compare two objects directly without comparing the setters individually.
    Thanks in advance.

    pavan13 wrote:
    That is pretty good idea. However I have a query. Does that code actually compare all the setters in a two beans. I don`t want to check each setter seperately.Well, it's pretty meaningless to talk about "comparing setters", setters are methods, they don't have values to compare. Because equals is inside the class, you can simply compare the fields that get set by the setters. "Properties" is probably a better name.
    In principal you could write something that tried to find all relevant fields and compare them, using reflection or bean info stuff. The resulting code would be about 50 times longer and take about 50 times longer to run. It's hardly asking a lot to put three comparisons between && operators.
    Remember, though, not to compare string fields with ==, you should call .equals on the string fields.
    p.s. don't let the bean terminology confuse you. Beans are just ordinary objects which follow a few rules. Personally I wish the term had never been coined.
    Edited by: malcolmmc on Dec 6, 2007 4:15 PM

  • af:panelGroup -- undefined object?

    Hi,
    Using ADF, I created a JSF jsp page that has three textboxes and two buttons-resetButton and submitButton. Trying to write some JavaScript code to make the resetButton work (clear the contents of all 3 textboxes). I was able to obtain the documet and form objects. But when I asked for panelGroup object, it returned me a undefined object, which means I cannot keep on tracking down to panelForm and inputText textboxes to reset their contents.
    Does anybody know how to solve it? Thanks.
    Annie

    Thank you very much for your reply. I appreciate it.
    I have been working on the Web Developer extension after reading your email. It is totally new to me and I am so happy to know that there is a powerful tool that can do so much for me.
    I downloaded "Internet Explorer Developer Toolbar" for IE. Opened my query page with "view DOM". In order to track down the compoent I want, I gave every component on the way an id. But I still won't be able to access underneath the first form. I was trying to type the source code here, but the format is so messy. Just delete it. Well, the tree is like this, form id=form1----div id=form1:queryPage----div id=form1:header----table id=form1:targetForm----tbody id=tbody1----tr id=tr1----td id=td1----table class=xs id=inndertable---- tbody id=tbody2----tr id=form1:ke__xc_----td id=td2----input class=x6 id=form1:ke
    My javascript is:
    alert(document.form1.form1:queryPage.id)
    I am sorry I could figure out how to copy it from the developer toolbar, so I typed. Hopefully you can get an idea how it looks. If I use "document.form1.id" it will return me "form1". But nothing underneath form1 can be accessed. Any help?
    Annie
    Message was edited by:
    user447669

  • FrameMaker 10 - Finding all graphics in a book with a Object Properties Scaling equal to 0%?

    Is there a way in FrameMaker 10 in the book to quickly find all imported graphics (.bmp, .cgm, .jpg, & .wmf) that are out-of-aspect ratio or where the Object Properties Scaling equals 0%?
    I import a lot of graphic (around a 100 or so) in FrameMaker 10 and I would like to be reassured that all imported graphic have the correct aspect ratio, and find any that are wrong quickly.
    I would like to be able to do this search in the Book format rather than each section.
    Is there a way to do this?
    Thanks!

    Denis, this would require scripting. ExtendScript would likely be the first choice and would be perfect for the job. Given that you want to operate on the whole book at once, the script would be a little bit longer, so you might not get someone to post it here for free. I would consider it because it would be a nice addition to the samples on my website, but I can't do it right this minute. If no one offers for free, hit me up in a day or two and I might be able to accommodate  you.
    One question though... are you really looking to verify the aspect ratio? This could be a considerably more complicated task. FrameMaker doesn't save the original ratio, so you would need to reimport the graphic into some other scratchpad area, calculate the aspect ratio, then compare it to the place of reference. I'm not sure that I could go that far.
    Alex, I think you may have misunderstood the question. Also, it's not even clear if these are structured files, and if so, if there is a structured application to save as XML.
    Russ

  • Change multiple object properties at one time

    I'm using Universal Designer and I have to manually change the properties of over 100 objects.  Does anyone know how I can change multiple object properties at one time?

    Hi,
    This links may be helpful to you,
    http://forumtopics.org/busobj/viewtopic.php?t=94828&sid=1eb4a78e88c26b14418c354d1321e350
    http://www.forumtopics.com/busobj/viewtopic.php?t=21029
    All the Best,
    Madhu...

  • WYSIWYG element HTML object properties disabled

    Hi,
    In WYSIWYG element HTML object properties link is getting disabled after entering value into the element. Is there any way to make it enable even after entering value.
    Thanks & Regards
    Prasad
    Server details:
    UCM 10gR3
    Site Studio 7.7
    Unix
    verity search

    Hi,
    you have to divide the process into several steps:
    get the image tag at the caret position
    read it' properties
    bring up a window with ooptions to change those properties
    remove the existing image tag
    place a new image tag with the new properties at the caret position
    alternately you can change the properties of the existing image tag.
    There a reloads of threads in this forum about how to change tag properties or the tag structure of a HTML document, so I omit this. Please try to do a search for such topics in this forum.
    A GUI (Java classes ImageDialog and ImagePreview) for entering image properties is available at http://www.calcom.de/eng/dev/index.htm
    Directly changing a table's width with the mouse is more complex, because you'd have to constantly write new width properties for the table and update the document while the mouse is moved. Probably better would be to bring up a dialog window to change the table properties instead.
    Hope this helps
    Ulrich

  • How do I center objects (photos and animations) so they stay centered with the other page elements?

    How do I center objects (photos and animations) so they stay centered with the other page elements?

    Geez .. Your class doesn't fulfill the javabean specifications. The properties should not be public.
    It should rather look likepublic class TheAddress {
        // Properties ---------------------------------------------------------------------------------
        private String address1;
        private String address2;
        // Constructors -------------------------------------------------------------------------------
        public TheAddress() {
            // Default constructor.
        public TheAddress(String address1, String address2) {
            // Full constructor.
            this.address1 = address1;
            this.address2 = address2;
        // Getters ------------------------------------------------------------------------------------
        public String getAddress1() {
            return address1;
        public String getAddress2() {
            return address2;
        // Setters ------------------------------------------------------------------------------------
        public void setAddress1(String address1) {
            this.address1 = address1;
        public void setAddress2(String address2) {
            this.address2 = address2;
    }

  • How to call request object of IPortalComponent in KM Scheduler application

    Hi
    We are reading RFC Table data using JCO Connection Pool(JCOClientPoolEntry. Please find the below teo line code.If we put this code in KM Scheduler application then its throwing error for the request objecct of IPortalComponenetRequest.
    IJCOClientPoolEntry jcoPoolEntry = null;
    jcoPoolEntry = clientService.getJCOClientPoolEntry(sysId, request);
    Can you please let me know how to use request object of IPortalComponent in KM Scheduler application?
    Thanks,
    Susmita

    Hello GopalY,
    In my experience its not possible to call OLE object in Webui. Maybe customer 3 party application will be supply some web service to handle credit card payments. I think this is the simple way to access 3party application.
    Regards,
    Zafer,

  • In Object Properties dialog box, modify "tab path"...

    For FrameMaker versions up to and including 8 (and I suspect 9).
    Select a graphic, then click in sequence
    ESC g o to open the
    Object Properties dialog box. By default the dialog box opens with the insertion point in the
    Width text entry area.
    Now press TAB four times: The insertion point moves sequentially to the
    Height,
    Top,
    Left, and then
    Color text entry areas.
    I wish the last movement, to the
    Color text entry area, was replaced with movement to the
    Percent text entry area. This would enable me to use the keyboard to efficiently configure the size, position, and scaling of a graphic.
    As it is, I virtually never need to select the graphic's
    Color text entry area and the movement of the insertion point to that essentially useless tool drives me crazy: It makes me TAB all the way 'round the dialog box or grab the pointing device to get it to the
    Percent text entry area...
    Cheers,
    Riley

    Odd... What does your properties dialog look like? Can you post a screenshot of the dialog box? Also, what version of LabVIEW are you running?
    Message Edited by smercurio_fc on 06-03-2008 04:56 PM

  • Hi,how can i transport objects from one server to other like (Dev To Qty)

    Hi Sir/madam,
       Can u explain how can i transport objects from one server to other like (Development To Quality To Production).
    Regards,
    Vishali.

    Hi Vishali,
    Step 1: Collect all Transports(with Packages) in Transports Tab(RSA1)- CTO
    Step 2: Release the subrequests first and then the main request by pressing Truck button
    Step 3: STMS or Customized transactions
    Object Collection In Transports:
    The respective Transports should have the following objects:
    1. Base Objects -
    a. Info Area
    b. Info object catalogs
    c. Info Objects
    2. Info Providers u2013
    a. Info Cubes
    b. Multi Providers
    c. Info Sets
    d. Data Store Objects
    e. Info Cube Aggregates
    3. Transfer Rules u2013
    a. Application Components
    b. Communication Structure
    c. Data Source replica
    d. Info Packages
    e. Transfer Rules
    f. Transformations
    g. Info Source Transaction data
    h. Transfer Structure
    i. Data sources (Active version)
    j. Routines & BW Formulas used in the Transfer routines
    k. Extract Structures
    l. (Note) If the transfer structures and related objects are being transferred without preceding
    Base Objects transport (e.g. while fixing an error) it is safer to transport the related Info
    Objects as well.
    4. Update Rules u2013
    a. Update rules
    b. Routines and formulas used in Update rules
    c. DTPs
    5. Process Chains u2013
    a. Process Chains
    b. Process Chain Starter
    c. Process Variants
    d. Event u2013 Administration Chains
    6. Report Objects u2013
    a. Reports
    b. Report Objects
    c. Web Templates
    Regards,
    Suman

  • How can we change the properties of a seeded item in OAF !!!

    Hi All Gurus!
    I have a seeded item (Button 'Apply') on an Add attachement page provided by Oracle in Self Service Web Module. Oracle documentation says this:
    If you want changes to the Attachments table or page to commit automatically, without requiring a user to select Apply in the base page, you can turn on "auto-commit" by setting the Automatic Save property to True for the attachmentLink, attachmentTable, or attachmentImage item.With "auto-commit" turned on, each action ("Add", "Update", "Detach") performed by the user in the Attachments table or page is automatically committed.
    Q1) How we can see the properties of the seeded items?
    Q2) How we can turn on the personalization pencil button of an item that is disabled by Oracle development team?
    Please let me know how we can achieve this through self-service personalization. Any light on this.
    Thanks in advance!
    John
    Message was edited by:
    jtom

    You donot need to do anything on the Add Attachment page. The autoCommit feature is exposed as a property on the Attachment bean. You need to extend the controller in the base page where the attachment Image, Link is present and get a handle to the attachmentBean and call setAutoCommit(true) which will enable automatic saving.Use personalizations to modify the controller class property on the base page. You can later choose to remove the Save button on base page using personalization.

  • How to delete all objects in a package?

    Hello,
    I've seen a similar question here. But is there a tool or a smart way to delete all objects in a dev class or a transport request?
    Best Regards
    Volker

    These are really 3 questions??
    1. To delete objects in a request there are a number of ways, here is one:
    Position cursor on modifiable request.
    Double click on request and choose 'Objects' tab
    Choose object line you want to delete and click 'Delete'
    Save your changes.
    2. To delete objects in a Dev Class:
    Go to work bench --> edit object, Class and give your class name, you will see delete option at the bottom of the screen.
    3. How to delete all objects in a package:
    here is a link with the steps you need for this: http://benxbrain.com/en/index.do?onInputProcessing(brai_object_thread)&001_threadid=0000161442&sysid=WP5&pgmid=R3TR&object=DOMA&obj_name=DEVCLASS&child_param=

  • How do I read a properties file in WEB-INF without hard-coding a path?

    Hello,
    How do I read a properties file in WEB-INF without hard-coding a path?
    I tried:
    Properties properties = new Properties();
    properties.load(new FileInputStream("db.properties"));
    driver = properties.getProperty("driver");
    but it cannot find the db.properties file.
    Thanks for the help.
    Frank

    Don't use a File to read those properties.
    Better to use the servlet context and
    getResourceAsStream() method to get the InputStream.
    It'll look for any file in the CLASSPATH. If you put
    that properties file in the WEB-INF/classes directory
    you'll have no problems, even if you deploy with a
    WAR file.Completely agree with this approach. Just have to mention the following for completeness
    according to the API,
    "This method is different from java.lang.Class.getResourceAsStream, which uses a class loader. This method allows servlet containers to make a resource available to a servlet from any location, without using a class loader. "
    So using this method, the resource can be anywhere under your web context, not just in the classpath.
    Cheers,
    evnafets

Maybe you are looking for