Javascript to duplicate every field

Is there a way to duplicate every instance of a field in a document?
I have a document with multiple fields (e.g. 'QTY.12345', 'QTY.12346', etc.) that occur in several places in the same document. Since I had no luck finding a way to set a field format to a non-javascript number format, I am trying to set up a script to duplicate every field wherever it exists in the document (the 'QTY.12345' field might exist on several pages, or more than once on the same page) and give the duplicated field the more advanced javascript functions.
I can use the following to get every field in the 'QTY' family:
var f = this.getField("QTY");
var a = f.getArray();
var v = 0.0;
for (j =0; j < a.length; j++) {
var fieldName = a[j].name
app.alert ("Master field: " + fieldName)
...but I don't know how to find where each copy of the field exists in the document.
My goal is to have a document which will give the user limited functionality if they have Javascript disabled, but will reveal the javascript enabled fields (and hide the non-js fields) and activate any javascript features on startup. When the file is closed, it will restore the document to the original non-javascript state.

Hi,
According to your description, there are three hidden fields in the NewForm page, users select a value in the “Customer” field. Before submit, you want to send a request
to query the corresponding values for the three hidden fields, then perform the submit.
Per my understanding, the logic of the code can be like this: hide the three fields after page loaded, in the PreSaveAction() function, use Client Object Model with
CAML query to retrieve the item needed, set value to the three hidden fields, then submit.
From your code, we can see that you are able to get/set value of fields in the NewForm page, retrieve item and extract the values needed in the query success callback
function. Yes, you are in the right way.
As you have accomplished all the main steps of this solution, in my opinion, the rest work would be to make them work smoothly together in your page for better user
experience.
Feel free to reply if there any question during the process.
Best regards,
Patrick
Patrick Liang
TechNet Community Support

Similar Messages

  • This is regarding printing vertical lines for each and every field

    Hi to all.....
    1....Hi
    here is a requirement
    i want to print vertical lines and horizontal lines for each and every field in the output of a report.Here i want to see the output just like table i.e i want to draw line after each field.
                             suppose if the output list contains just 10 records, then the vertical line must end for 10 records.how to draw vertical lines for this requirement.
    thanks and regards,
    k.swaminath

    Hi
    In report you can use
    sy-uline for horizontal line
    sy-vline for vertical lines.
    Check this sample report
    DATA: BEGIN OF USR_TABL OCCURS 0.
    INCLUDE STRUCTURE UINFO.
    DATA: END OF USR_TABL.
    DATA: L_LENGTH TYPE I,
    T_ABAPLIST LIKE ABAPLIST OCCURS 0 WITH HEADER LINE, BEGIN OF T_USER OCCURS 0, COUNTER TYPE I, SELECTION TYPE C, MANDT LIKE SY-MANDT, BNAME LIKE SY-UNAME, NAME_FIRST LIKE V_ADRP_CP-NAME_FIRST, NAME_LAST LIKE V_ADRP_CP-NAME_LAST, DEPARTMENT LIKE V_ADRP_CP-DEPARTMENT, TEL_NUMBER LIKE V_ADRP_CP-TEL_NUMBER, END OF T_USER, L_CLIENT LIKE SY-MANDT, L_USERID LIKE UINFO-BNAME, L_OPCODE TYPE X, L_FUNCT_CODE(1) TYPE C, L_TEST(200) TYPE C.
    L_OPCODE = 2.
    CALL ‘ThUsrInfo’ ID ‘OPCODE’ FIELD L_OPCODE
    ID ‘TAB’ FIELD USR_TABL-*SYS*.
    CLEAR T_USER. REFRESH T_USER.
    LOOP AT USR_TABL.
    T_USER-MANDT = USR_TABL-MANDT. T_USER-BNAME = USR_TABL-BNAME. APPEND T_USER.
    ENDLOOP.
    SORT T_USER.
    DELETE ADJACENT DUPLICATES FROM T_USER.
    LOOP AT T_USER.
    T_USER-COUNTER = SY-TABIX. SELECT V~NAME_FIRST V~NAME_LAST V~DEPARTMENT V~TEL_NUMBER INTO (T_USER-NAME_FIRST, T_USER-NAME_LAST, T_USER-DEPARTMENT, T_USER-TEL_NUMBER) FROM USR21 AS U JOIN V_ADRP_CP AS V ON U~PERSNUMBER = V~PERSNUMBER AND U~ADDRNUMBER = V~ADDRNUMBER WHERE U~BNAME = T_USER-BNAME. ENDSELECT. MODIFY T_USER.
    ENDLOOP.
    SORT T_USER BY NAME_LAST NAME_FIRST.
    PERFORM DISPLAY_LIST.
    TOP-OF-PAGE.
    PERFORM DISPLAY_MENU.
        * End of top-of-page
    TOP-OF-PAGE DURING LINE-SELECTION.
    PERFORM DISPLAY_MENU.
        * End of top-of-page during line-selection
    AT LINE-SELECTION.
    IF SY-CUROW = 2. IF SY-CUCOL < 19. T_USER-SELECTION = ‘X’. MODIFY T_USER TRANSPORTING SELECTION WHERE SELECTION = ‘’. PERFORM DISPLAY_LIST. ELSEIF SY-CUCOL < 36. CLEAR T_USER-SELECTION. MODIFY T_USER TRANSPORTING SELECTION WHERE SELECTION = ‘X’. PERFORM DISPLAY_LIST. ELSEIF SY-CUCOL < 50. PERFORM TRANSFER_SELECTION. PERFORM POPUP_MSG. ELSEIF SY-CUCOL < 67. PERFORM TRANSFER_SELECTION. SORT T_USER BY NAME_LAST. PERFORM DISPLAY_LIST. ELSEIF SY-CUCOL < 81. PERFORM TRANSFER_SELECTION. SORT T_USER BY NAME_FIRST. PERFORM DISPLAY_LIST. ELSEIF SY-CUCOL < 93. PERFORM TRANSFER_SELECTION. SORT T_USER BY MANDT. PERFORM DISPLAY_LIST. ENDIF. ENDIF.
        * End of line-selection
    *& Form DISPLAY_LIST
    FORM DISPLAY_LIST.
    SY-LSIND = 0.
    FORMAT COLOR COL_NORMAL INTENSIFIED OFF.
    LOOP AT T_USER.
    WRITE: / SY-VLINE, T_USER-SELECTION AS CHECKBOX, SY-VLINE, T_USER-MANDT, SY-VLINE, T_USER-BNAME, SY-VLINE, T_USER-NAME_FIRST(15), SY-VLINE, T_USER-NAME_LAST(15), SY-VLINE, T_USER-DEPARTMENT, SY-VLINE, T_USER-TEL_NUMBER(20), SY-VLINE. HIDE: T_USER-COUNTER, T_USER-SELECTION.
    ENDLOOP.
    FORMAT COLOR OFF.
    WRITE: /(108) SY-ULINE.
    ENDFORM. ” DISPLAY_LIST
    *& Form DISPLAY_MENU
    FORM DISPLAY_MENU.
    FORMAT COLOR COL_HEADING HOTSPOT. WRITE: (91) SY-ULINE, / SY-VLINE NO-GAP, (4) ICON_SELECT_ALL NO-GAP, ‘Select All’, SY-VLINE NO-GAP, (4) ICON_DESELECT_ALL NO-GAP, ‘Deselect All’, SY-VLINE NO-GAP, (4) ICON_SHORT_MESSAGE NO-GAP, ‘Send Popup’, SY-VLINE NO-GAP, (4) ICON_SORT_UP NO-GAP, ‘Last Name’ NO-GAP, SY-VLINE NO-GAP, (4) ICON_SORT_UP NO-GAP, ‘First Name’ NO-GAP, SY-VLINE NO-GAP, (4) ICON_SORT_UP NO-GAP, ‘Client’ NO-GAP, SY-VLINE, /(91) SY-ULINE, /(108) SY-ULINE. FORMAT HOTSPOT OFF. WRITE: / SY-VLINE, ’ ‘, SY-VLINE, ‘Cli’, SY-VLINE, ‘User ‘, SY-VLINE, ‘First Name ‘, SY-VLINE, ‘Last Name ‘, SY-VLINE, ‘Department ‘, SY-VLINE, ‘Telephone ‘, SY-VLINE, /(108) SY-ULINE. FORMAT COLOR OFF.
    ENDFORM. ” DISPLAY_MENU
    *& Form TRANSFER_SELECTION
    FORM TRANSFER_SELECTION.
    DO. READ LINE SY-INDEX FIELD VALUE T_USER-SELECTION. IF SY-SUBRC <> 0. EXIT. ENDIF. MODIFY T_USER TRANSPORTING SELECTION WHERE COUNTER = T_USER-COUNTER. ENDDO. CLEAR T_USER.
    ENDFORM. ” TRANSFER_SELECTION
    *& Form POPUP_MSG
    FORM POPUP_MSG.
    DATA: L_MSG LIKE SM04DIC-POPUPMSG VALUE ‘Experimental Message’, L_LEN TYPE I, L_RET TYPE C. LOOP AT T_USER WHERE SELECTION = ‘X’. PERFORM GET_MESSAGE CHANGING L_MSG L_RET. EXIT. ENDLOOP. IF L_RET = ‘A’. “User cancelled the message EXIT. ENDIF.
        * Get the message text
    L_LEN = STRLEN. LOOP AT T_USER WHERE SELECTION = ‘X’. CALL FUNCTION ‘TH_POPUP’ EXPORTING CLIENT = T_USER-MANDT USER = T_USER-BNAME MESSAGE = L_MSG MESSAGE_LEN = L_LENGTH
        * CUT_BLANKS = ’ ’
    EXCEPTIONS USER_NOT_FOUND = 1 OTHERS = 2. IF SY-SUBRC <> 0. WRITE: ‘User ‘, T_USER-BNAME, ‘not found.’. ENDIF. ENDLOOP. IF SY-SUBRC <> 0.
        * Big error! No user has been selected.
    MESSAGE ID ‘AT’ TYPE ‘E’ NUMBER ‘315’ WITH ‘No user selected!’. EXIT. ENDIF.
    ENDFORM. ” POPUP_MSG
    *& Form GET_MESSAGE
    FORM GET_MESSAGE CHANGING P_L_MSG LIKE SM04DIC-POPUPMSG
    P_RETURNCODE TYPE C.
    DATA: BEGIN OF FIELDS OCCURS 1. INCLUDE STRUCTURE SVAL.
    DATA: END OF FIELDS, RETURNCODE TYPE C.
    FIELDS-TABNAME = ‘SM04DIC’.
    FIELDS-FIELDNAME = ‘POPUPMSG’.
    FIELDS-FIELDTEXT = ‘Message :’. CONCATENATE ’ – Msg from’ SY-UNAME ‘.’ INTO FIELDS-VALUE SEPARATED BY ’ ‘. APPEND FIELDS.
    CALL FUNCTION ‘POPUP_GET_VALUES’
    EXPORTING POPUP_TITLE = ‘Supply the popup message’
    IMPORTING RETURNCODE = P_RETURNCODE
    TABLES FIELDS = FIELDS.
    IF P_RETURNCODE = ‘A’.
    EXIT.
    ELSE.
    READ TABLE FIELDS INDEX 1.
    P_L_MSG = FIELDS-VALUE.
    ENDIF.
    ENDFORM. ” GET_MESSAGE
    *—End of Program
    Regards
    Pavan

  • PDF Form javascript for making readonly field by using button

    Please let me know the PDF Form JavaScript for making selected fields(Text field,Drop down list,..) as read-only by using Button.

    Do you want your button to be made read only?
    One starts with Acrobat JS Reference.
    // make all fields in a form read only;
    var oField; // variable for field being processed;
    // loop through the form fields;
    for (var i = 0; i < this.numFields; i++) {
    // process each field name;
    oField = this.getField(this.getNthFieldName(i)).readonly = true;

  • Acces to data of every field in a table using a loop

    Hello:
    I have the next code:
    // Calling remote function
    proxy.Z_Hrpfpa00105("XX", "45", out sts, ref tIVAEmp);
    foreach (ZHRRESNOM row in tIVAEmp)
      { Console.WriteLine("{0} …", row.Desc2, row.Betrg, …); }
    Assuming that tIVAEmp has 100 fields I need to build some loops during Console.WriteLine process, so I asked for your help for one part of the solution:
    // Getting the field names and lengths of an RFC Table
    Type structureType = tIVAEmp.GetElementType();
    SAPField[] fields = SAPStructure.GetSAPFieldsSchema(structureType);
    // Verifying
    foreach (SAPField row in fields)
        Console.WriteLine(" - ", row.FieldName,  row.FieldLength);
    It worked, but now I can´t find the connection between SAPField and the content of every RFC Table field for every record,  my mind is in blank and a I need  help … how can I do in C# something similar to:
    foreach (ZHRRESNOM row in tIVAEmp)
    +// The next is pseudo-code
       for every field F in fields
         { stri += contents of row, column F }
       Console.WriteLine(“”, stri);+</i></i>
    Thanks again

    E.g
    proxy.Z_Hrpfpa00105("XX", "45", out sts, ref tIVAEmp);
    Type structureType = tIVAEmp.GetElementType();
    SAPField[] fields = SAPStructure.GetSAPFieldsSchema(structureType);
    foreach (ZHRRESNOM row in tIVAEmp)
      foreach (SAPField field in fields)
        Console.WriteLine("{0}: {1}", field .FieldName, row[field.FieldName]);
    Accessing fields by name may be a little bit slow. Alternatively you can access it by index, which is faster:
      for (int i=0; i<fields.Length; i++)
        Console.WriteLine("{0}: {1}", fields<i>.FieldName, row<i>);

  • Need a pipe delimiter after every field in the file on application server

    Hi ,
    i have to transport data in internal table to a file on application server.
    I have done this successfully. But the problem is i have to put a pipe
    delimiter after every field in the file on application server.
    Could yoe plz help in  this issue.
    Thanks & Regards
    Suresh kumar D

    Hi Should,
              I think the below code should solve your problem as i also had  a similar type of requirement and this was the code i had used in my program.
      FIELD-SYMBOLS: <FS> TYPE ANY.
      DATA: L_FLINE TYPE STRING.
    Open file for output
      M_CHECK_SELSCR_FNMS O1 O.
      LOOP AT I_TARGET.
    Write records to file
        DO.
          ASSIGN COMPONENT SY-INDEX OF STRUCTURE I_TARGET TO <FS>.
          IF SY-SUBRC EQ 0.
            IF SY-INDEX EQ 1.
              MOVE <FS> TO L_FLINE.
            ELSEIF <FS> NE C_PIPE.
              CONCATENATE L_FLINE C_PIPE <FS> INTO L_FLINE.
            ELSE.
              CONCATENATE L_FLINE <FS> INTO L_FLINE.
            ENDIF.
          ELSE.
            TRANSFER L_FLINE TO W_SRVR_NM_O_O1.
            EXIT.
          ENDIF.
        ENDDO.
      ENDLOOP.
    Close file
      CLOSE DATASET W_SRVR_NM_O_O1.
      IF SY-SUBRC EQ 0.
        MESSAGE S208(00) WITH TEXT-M02.
      ENDIF.
    Regards
    Sikha

  • Duplicate form fields across multi-page forms

    Hello!
    I have some multi-page forms which include a few identically laid out pages; pages which take a long time to manually set up (nearly 100 fields per page, of varying sizes and positions)...
    I tried to duplicate the fields from one page to the others, which worked; but they are identical fields, meaning text input into one will likewise be seen in the other pages. I need the other pages to be unique, even though they look identical (field-wise they look identical, the background images for my form distinguish the actual contents of each field).
    Copy/Paste is the same as duplicate.
    I can just do that and then manually rename a few hundred fields; but at that point I am not much better off than manually placing the fields. Some, but not much.
    Is there any way to do this?

    I would look at using the template object within for this task.

  • Add one same literal to each and every field in a collection

    I need to add a semicolon to each and every field in my collection (I will afterwards write it to a CLOB and have the data opened in Excel as a CSV file).
    I mean I have a nested table with, say 10 fields. For each index in the collection, I need to build a string wich would be a concatenation of each and every value of all this index's fields - separated by a semicolon.
    Example:
    Say my nested table is my_collec, and it has 10 fields, col1, col2... col10.
    I have obtained my string the hard way - v_string := my_collec(1).col1 || ';' || my_collec(1).col2 || ';' ||... and so forth, till my_collec(1).col10.
    As I said, I have to do this for every index of my collection, so I would do that in a loop, rendering v_string := my_collec(2).col1 || ';' || my_collec(2).col2 || ';' ||... and so forth, till my_collec(2).col10 ... till the my_collec.last.
    Is there any built in method that allows me to loop through all a collection's fields/attributes ?
    Edited by: Veverke on Apr 25, 2010 2:49 PM
    Edited by: Veverke on Apr 25, 2010 2:55 PM

    Can you explain more what you mean with a collection?
    A small, simplified example?
    If not, any suggestions ?Maybe OWA_SYLK can be of use to you.
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:769425837805
    More threads:
    http://asktom.oracle.com/pls/asktom/asktom.search?p_string=%22owa_sylk%22

  • InDesign cs3 javascript to duplicate layer

    Greetings, I'm looking for an example javascript that duplicates an indesign cs3 layer, renames the new layer that gets duplicated and turns printing off on the original layer. Any help is appreciated. Wil

    Hi Wil,
    Try the following code:
    var myDoc = app.activeDocument;
    var myLayer = "Sample"; //Add your layer name here
    var NewLayer = myDoc.layers.item(myLayer).duplicate();
    myDoc.layers.item(myLayer).visible = false;
    NewLayer.name = "SampleNew";
    I think this will solve your problem.
    Regards,
    Ramkumar

  • Why not index every field in a database

    Hello,
    I hope this is not to much of a newbie question. We have a database that is being used by an application. We do not know which fields are queried on, the application allows for any/all field(s) to be searched on.
    Obviously, we can know which fields a particular method is searching on, but there is no requirement for the application developers to keep us up to date on particular query parameters as they add them.
    This is a 10g, soon to be 11g, database. Most of the fields are integer with less than 2 digits.
    My question is, why not simply index every field, or at least every small integer field?
    Thanks,
    Sammer

    user613816 wrote:
    Hello,
    I hope this is not to much of a newbie question. We have a database that is being used by an application. We do not know which fields are queried on, the application allows for any/all field(s) to be searched on.
    Obviously, we can know which fields a particular method is searching on, but there is no requirement for the application developers to keep us up to date on particular query parameters as they add them.
    This is a 10g, soon to be 11g, database. Most of the fields are integer with less than 2 digits.
    My question is, why not simply index every field, or at least every small integer field?
    Thanks,
    SammerIn addition to the unnecessary overhead, there are other considerations that affect whether Oracle will use an index. Just because it is there doesn't mean it will or should be used.
    Think about this:
    You have a table with a particular field, and an index on that field. You want to add up all the values of that field. Do you think it would be faster for oracle to just read all of those rows in the table and add them up, all of the rows in the index and add them up, or read the index, go find the row in the table, read the index, get another random row in the table...
    Now, what if Oracle can read more data at a time if it is getting all the data?
    What if you don't want the data from every row in the table? Are you going to create an index for every combination of columns?
    What if Oracle stores two digit integers no differently than 4 digit?
    What if 99.99% of the values are 0? 100%?
    How does Oracle decide the best way to get the data?
    These are all questions you can look up online. I would strongly suggest starting with the Oracle Concepts manual for the soon to be version. Once you have done that, you may see you don't have to apologize about newbie questions as long as people see you are willing to put some work into letting them help you.
    Some people claim there is no such thing as a stupid question. I think that is just pabulum to keep people from being scared to ask questions when they ought to. The stupid question is the one you ought to have known better before you asked. So your question wasn't a stupid question, but any others you ask now that you know about documentation and online searching may very well be.

  • Why do my photos duplicate every time my external hard drive is plugged in? iPhoto

    My photos are stored on my external hard drive and they duplicate every time I reconnect the EHD.
    Is there something in iPhoto preferences that will fix this?

    Moe information needed
    Like details - where do you see these duplicated photos - are you saying that reconnecting the EHD when iPhoto is not running duplicated photos? Where
    is this a default "managed" library (the iPhoto preference to "copy imported items to the iPhoto library is in its checked state) or a referenced library (you have unchecked that option)
    LN

  • Modification date of every field

    Hi gurus,
    I need to get the date of modification of every field in a specific table. I'm working under Oracle9, and the undo retention is too small to try select ... as of ...
    Restoring is not an option. I have been told that there is a way to find when was modified every field on a table, but I can't find the solution.
    Any help would be appretiated.
    Regards,
    Mario Alcaide

    Hi,
    take a look at LogMiner
    regards
    vlado

  • The Contacts app on my Mac somehow duplicates every entry.

    The Contacts App on my Mac somehow duplicates every entry. Running Card/FindDuplicates produces a report that there are no duplicates. How do I erase the duplicates and stop their reappearance?

    Resolving duplicate Contacts after setting up iCloud Contacts
    2 apple IDs causing Contacts problems

  • Javascript to fill text field from other PDF form

    I am trying to figure out if it is possible to add javascript to a text field that when initiated pulls text from another field in a closed pdf in the same directory.
    For example I have a NAME field in the pdf form I am working in....
    When I initiate the script the NAME field is filled in with the same data from another PDF that is closed.

    I have looked up the 'disclosed' property and it looks like that is what I want to do..
    I have "this.disclosed = true" in a PDF with the name field. On the other PDF that I want the information replicated I am going to add a javascript to an action somewhere on the document, my problem is which script do I use to get this data from the other pdf?  Is the pdf that is now accessible via javascript (disclosed) a data object?

  • Javascript to adjust form field font size by number of entered characters?

    I have a form field that asks for 'full name' (first, middle, last). It's posted large at the top of the form. Some people's names are short, some long.
    Is there a javascript way to adjust the font size used within a form field based on the number of characters entered into field?
    i.e. if the name entered is Joe Smith, the font size is 30pt, if it's Alexander Hamilton the font size is 20pt?
    Thanks!

    Uhm... because I never noticed that option before! hehe. Jeez.
    Gilad, thx much. That's exactly what I was looking to accomplish.
    (An aside: trying to find a specific Adobe solution or function isn't very easy. I always search the forums, the documentation, and Google before posting any question here. Seems like there are so many features in every product that change so frequently that finding even a simple answer is a challenge...)

  • Javascript submit XFDF every few minutes?

    I programmatically create a PDF and display it to a person on my web app. I use javascript to setup a submit of the XFDF data to another web page which then saves the data to a database so I can recall it later and repopulate the PDF when the bring it up again. Sometimes these PDFs can take a long time to fill out so I was wondering, is there a way to use Javascript to be able to automatically send the XFDF to a file or web page every few minutes as sort of an autosave feature but not take them away from the PDF. I used to program all the form fields in HTML and use Javascript to iterate through the fields and save it to the server every few minutes, but now that I'm displaying the PDF in its native format, I'd like to incorporate something like this so that users won't lose all their changes should their computer die at a certain point or they lose connection to the web app at some point.
    I'm using C# and asp.net BTW.
    John

    You can use the submitForm JavaScript method to submit the data: http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.537.html
    The response from your server script could be just the HTTP "204 No Content" type header.
    To submit at regular intervals, you can use the app.setInterval method: http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.165.html
    Finally, the user will have to allow the submit action, the first time at least.

Maybe you are looking for

  • Why does my ipad2 suddenly exit the apps I use ?

    How come that sometimes when I'm using my ipad2,it suddenly exits the app I'm using & go's back to my home screen?

  • Developer6i Net8 client and OID/LDAP

    Is it possible to get the Net8 client that comes with Devloper 6i to be able to speak LDAP to OID? Even though it has the 'i' suffix, it does not seem to have the 'internet' capabilties that could be used with OID? Is there a patch or an upgrade? I t

  • Need code for padding (spacing) 5 navigation links in my #topnavbar internal style

    need code for padding (spacing) 5 navigation links in my #topnavbar internal style

  • ORA-29534 itextpdf-5.2.1 11g

    Hi Evereryone. I need make some pdf's from pl-sq, I have java code to generate some reports, this code needs itext5.2.1 library, but the database trhows ORA-29534 error when I load itext5.2.1 jar file (with loadjava). Database: Oracle Database 11g R2

  • Hyperlinks Don't Open New Window

    I've noticed that when someone includes a hyperlink in their post, clicking on it opens the link in the active window rather than launching a new window as in the past. Twas better, (IMMHO) the "old" way....