AppleScript- filtering a list of records by a property value possible?

How can a list of records like the one below (except each list has 82 items) be filtered by a field's value so that the resulting list contains only records with a given property value?
e.g.
set recordList to (*input follows*) {{fnum:1, fname:"Admin", fval:"", isCustom:true},{fnum:8, fname:"Cataloged", fval:"4/18/12 4:04 PM", isCustom:false}}
I tried:
items of recordList where isCustom is true
but instead of the desired result( below) I got "variable isCustom not defined."
{{fnum:1, fname:"Admin", fval:"", isCustom:true}} --desired result
Is there a better way to do this than loop through the list and build a new list by evaluating the labeled pair of each record in the list?
Thanks in advance for any insights.

Hello Thomas Camilleri,
Short answer is no.
Filter reference form is only applicable to application objects and processed by the application.
Long answer is that you can define some handlers to make code concise though you cannot avoid iteration through the list. After all, even the filter reference form invokes iteration behind the scene, so the ultimate question here would be how well we can hide the iteration from the scene.
E.g., something like the codes below. Inevitable iteration is hidden in general-purpose handlers map() or match() and you may only define the filter1() or pattern1() handlers for your specific purpose. SCRIPT 2 would be better fit for your object.
Regards,
H
-- SCRIPT 1
set rr to {{key1:10, key2:true}, {key1:14, key2:false}, {key1:16, key2:true}}
set rr1 to map(filter1, rr)'s records
return rr1 -- {{key1:16, key2:true}}
on filter1(x)
    if x's key2 and x's key1 > 11 then return x
    return missing value
end filter1
on map(func, aa)
    script o
        property xx : aa's contents
        property yy : {}
        property f : func
        repeat with x in my xx
            set end of my yy to my f(x's contents)
        end repeat
        return my yy's contents
    end script
    tell o to run
end map
-- END OF SCRIPT 1
-- SCRIPT 2
set rr to {{key1:10, key2:true}, {key1:14, key2:false}, {key1:16, key2:true}}
set rr2 to match(pattern1, rr)
return rr2 -- {{key1:16, key2:true}}
on pattern1(x)
    x's key2 and x's key1 > 11
end pattern1
on match(pat, aa)
    script o
        property xx : aa's contents
        property yy : {}
        property f : pat
        repeat with x in my xx
            set x to x's contents
            if f(x) then set end of my yy to x
        end repeat
        return my yy's contents
    end script
    tell o to run
end match
-- END OF SCRIPT 2

Similar Messages

  • AppleScript 10.9.0 System Events -10006  Update property list file item

    Have AppleScript that runs without error on Mountain Lion 10.8.5, but errors out on Mavericks  10.9.0.
    At end of script, property list items need to be updated and this is when error occurs.
    Put together a subset of the script, see below) that get the error
    Statement reads "set value of property list item "ArrayList001" to ArrayList001"
    Text of error:
         error "System Events got an error: 'xxx.plist' is not a property list file."
         number -10006 from contents of property list file "xxx05.plist"
    =============================================================================
    property myPListFile : "cbmck05.plist"
    property myPListFilePath : ""
    property constPreviousRunDay : "PreviousRunDay"
    on run
       set today to "Date01" as string
              set List001 to {}
              set List002 to {}
              set myPListFilePath to ""
              repeat with i from 1 to 8
                        set end of List001 to (i * 2) as string
              end repeat
              set myPListFilePath to path to desktop folder from user domain as string
              set fileMyPList to (myPListFilePath & myPListFile) as string
    clear_file(fileMyPList)
    -- First time! need to initalize
              tell application "System Events"
      -- create an empty property list dictionary item
                        set the parent_dictionary to make new property list item with properties {kind:record}
      -- create new property list file using the empty dictionary list item as contents
                        set new_plistfile to ¬
      make new property list file with properties {contents:parent_dictionary, name:fileMyPList}
      make new property list item at end of property list items of contents of new_plistfile ¬
      with properties {kind:string, name:constPreviousRunDay, value:today}
      make new property list item at end of property list items of contents of new_plistfile ¬
                                  with properties {kind:list, name:"ArrayList001"}
      make new property list item at end of property list items of contents of new_plistfile ¬
                                  with properties {kind:list, name:"ArrayList002"}
              end tell
              set previousRunDate to today
              set xxList to (repopulate_lists())
              set ArrayList001 to List001
              set ArrayList002 to List002
    -- save info in the plist file
              tell application "System Events"
                        tell property list file fileMyPList
                                  tell contents
                                            set value of property list item constPreviousRunDay to previousRunDate
                                            set value of property list item "ArrayList001" to ArrayList001     --   <<< ------- error caused by the statement
                                            set value of property list item "ArrayList002" to ArrayList002
                                  end tell
                        end tell
              end tell
    end run
    -- ==========================================
    on repopulate_lists()
              set newList to {}
              set List002 to {}
              repeat with i from 1 to 8
                        set end of newList to i as string
              end repeat
              set List001 to newList
              return List001
    end repopulate_lists
    -- ==========================================
    -- Does the file exist?
    on fileExists(f)
              try
      f as string as alias
                        return true
              on error errMsg number errNum
                        return false
              end try
    end fileExists
    -- Delete the  files if exist
    on clear_file(aFile)
              if fileExists(aFile) then
                        tell application "Finder"
                                  set resultObject to delete aFile
                        end tell
              end if
    end clear_file

    Here's an AppleScript handler that partially works around this bug (warning: it turns each list item into a string).
    on plistWrite(plistPath, plistItemName, plistItemValue)
      -- version 1.1, Daniel A. Shockley
      -- 1.1 - rough work-around for Mavericks bug where using a list for property list item value wipes out data
              if class of plistItemValue is class of {"a", "b"} and AppleScript version of (system info) as number ≥ 2.3 then
      -- Convert each list item into a string and escape it for the shell command:
      -- This will fail for any data types that AppleScript cannot coerce directly into a string.
                        set plistItemValue_forShell to ""
                        repeat with oneItem in plistItemValue
                                  set plistItemValue_forShell to plistItemValue_forShell & space & quoted form of (oneItem as string)
                        end repeat
                        set shellCommand to "defaults write " & quoted form of POSIX path of plistPath & space & plistItemName & space & "-array" & space & plistItemValue_forShell
      do shell script shellCommand
                        return true
              else -- handle normally, since we aren't dealing with Mavericks list bug:
                        tell application "System Events"
      -- create an empty property list dictionary item
                                  set the parent_dictionary to make new property list item with properties {kind:record}
                                  try
                                            set plistFile to property list file plistPath
                                  on error errMsg number errNum
                                            if errNum is -1728 then
                                                      set plistFile to make new property list file with properties {contents:parent_dictionary, name:plistPath}
                                            else
                                                      error errMsg number errNum
                                            end if
                                  end try
                                  tell plistFile
                                            try
                                                      tell property list item plistItemName
                                                                set value to plistItemValue
                                                      end tell
                                            on error errMsg number errNum
                                                      if errNum is -10006 then
      make new property list item at ¬
                                                                          end of property list items of contents of plistFile ¬
      with properties ¬
                                                                          {kind:class of plistItemValue, name:plistItemName, value:plistItemValue}
                                                      else
                                                                error errMsg number errNum
                                                      end if
                                            end try
                                  end tell
                                  return true
                        end tell
              end if
    end plistWrite

  • SharePoint: Workflow to retrieve all users and Create list item record for each user

    Hi all,
    My share point site have two Lists as Holidays and MyCalender.
    Actually Holiday is simple non-Calender list with field as Holiday Date, Reason. MyCalender List Calender type list with Person Look-up column and user can see his own record. User of Manager group will declare holiday. This Holiday should get reflected
    on each user 's MyCalender List.[One listitem as holiday date and reason for each user] so everyone can view that record.
    I have requirement as Manager will create one Holiday record and then run single workflow so for all users present in SharePoint Site, one MyCalender List Item record should get created. Is it possible to do using Workflow?? Please help as I didn't get any
    solution for this.. Thanks in advance!

    You don't need one workflow per user when a filtered view can do this for you.  If the manager's list is the parent calendar, I'm assuming that he'll be at least using the person look-up column.
    Whether this feeds through the MyCalendar or stays where it is, you can use the [Me] parameter within the filter on a new view.  This will then return the assigned holiday filtering against the account that is logged in.
    Steven Andrews
    SharePoint Business Analyst: LiveNation Entertainment
    Blog: baron72.wordpress.com
    Twitter: Follow @backpackerd00d
    My Wiki Articles:
    CodePlex Corner Series
    Please remember to mark your question as "answered" if this solves (or helps) your problem.

  • Filtering a list using multiple filters with Parameters, if one filter empty no results returned. How to fix?

    Hi All,
    I would assume this is a common problem. 
    I am a having problems using filters on SharePoint 2013 Lists on a custom site page.
    I am using the Filter (text, date, Choice) Web Parts, however due to the limitations of the filter web parts, I am also using Parameters and the Filters from within SharePoint designer.  Using this method, I am able to search date ranges and partial
    text on set columns.   The problem is that I have to fill out all the filter fields in order to get any results.  If a filter is left blank then the list should only filter on the other filters.  Instead it no results are returned.
    In addition, if I do set the filters, how do you reset the filters to show all records again?
    Thanks

    The only way I've figured out is to create a field that is always empty, e.g., a calculated text field, and use that field to "test" if the parameter is blank.  Here's an example CAML query fragment:
                    <Or>
                      <Contains>
                        <FieldRef Name="WorkflowDocsDescription"/>
                        <Value Type="MultiLookup">{DocDescriptionTextFilterValue}</Value>
                      </Contains>
                      <Eq>
                        <FieldRef Name="Empty"/>
                        <Value Type="Text">{DocDescriptionTextFilterValue}</Value>
                      </Eq>
                    </Or>
    This may not perform well in a large list, but perhaps an index on the Empty field would remedy.
    GShore

  • More than maximum 5 filtered album lists trying to register. This will fail,Why i am getting this error when i pick video from Photo library.

    I am able to pick 4 videos from the Photo library in my iPhoneAPP but when i try to pick 5th one it throws an error:
    "More than maximum 5 filtered album lists trying to register. This will fail,Why i am getting this error when i pick video from Photo library."

    Hello Tate r Bulic
    I don't have any idea how to remove this error,can i pick more than 5 videos from the photo library...
    If it's then please help me and gimme idea..Thanks

  • How To Insert List of Record To the Database Using Linq

    Good day every one, Please i need little help, I have a list of record like this
    lblID.Text = string.Join("<br/>", numbers);
    gives the Numbers below...
    6131
    5241
    3978
    6824
    3842//To Save to the database
    int pin = int.parse(lblID.Text);
    Now i want to insert those Numbers to the database
    Persons ps = new Persons();
    ps.Number = pin;
    cdc.Persons.AddObject(ps);
    cdc.SaveChanges();
    it throws up error...
    what i want to achieve on button insert
    all Numbers will be inserted but before inserting the number it will check if those numbers exist first on the database
    it should be like this on the database
    ID Number
    1 6131
    2 5241
    3 3978
    4 6824
    5 3842
    thanks.. I do appreciate your time and effort

    Hello,
    >>Now i want to insert those Numbers to the database
    For inserting a list of items to database, a loop statement is needed. I do not how you get these numbers, I assume they are stored in a collection and you could check below demo sample to insert these numbers and I assume your person table is identified:
    using (DFDBEntities db = new DFDBEntities())
    List<int> numbers = new List<int>() { 6131, 5241, 3978, 6824, 3842 };
    for (int i = 0; i < numbers.Count; i++)
    int number = numbers[i];
    //Check if the local and database already contains this number
    bool isRecordExist = db.Tables.Any(t => t.Number == number) || db.Tables.Local.Any(t => t.Number == number);
    if (!isRecordExist)
    Table t = new Table();
    t.Number = number;
    db.Tables.Add(t);
    db.SaveChanges();
    Regards.
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Dynamic List of record subsets with a Many-to-many relationship

    I'm feeling pretty lost here and would appreciate any pointers.
    I'm trying to use ADDT to create a dynamic list of records that includes a subset of comma separated list of many-to-many related records. Specifically I'm listing a bunch of workshops that have various teachers associated with each workshops. Teachers team teach a variety of workshops, thus the need for a many-to-many link table.
    I've created a basic query to retrieve the workshop list, then another query to return the teacher's associated with the workshops. However I can't figure out how to use ADDT to list the teachers for each workshop.
    I have a sense that it has something to do with a nested repeat region but there does not seem to be a way to get the wizard to see beyond the link table.
    Am I way off here?
    Thanks!

    Hi,
    a list used in the singleSelectOne component does not change or set the currency in the list VO (in opposite to the navigation list). So this synchronization needs to be done programmatically. Examples of dependent list of values are available here
    --> example 62 http://radio.weblogs.com/0118231/stories/2004/09/23/notYetDocumentedAdfSampleApplications.html
    --> word document you can download from http://thepeninsulasedge.com/frank_nimphius/2008/05/16/blogbuster-treasures-hunt-blog-entries-from-the-lost-orablogs-blog-for-download/
    Frank

  • Very urgent..........how to pass a paramter list containing record group as

    hi
    can any one help me , i am getting frm-41214 when i pass a paramter list containing record group as data parameter to run_report_object as parameter, calling report from forms 10g, but when i dont pass the parameter list the report runs displaying no data(as it should do), otherwise it dont run and display the frm-41214
    zulfiqar

    Hi,
    Try using a lexical parameter(&parm_1) for a string of values or a bind parameter(:parm_1) for a single value
    Thanks,
    Kimosabe

  • URGENT,FRM-41337: Cannot populat the list from record group

    Hi all:
    Can anyone help me in that problem?
    I have a database item in the block as a list item with combo box style and I use this code in WHEN-NEW-RECORD-INSTANCE at the form module level to populate that combo box list:
    DECLARE
         group_id RECORDGROUP := FIND_GROUP('group');
         list_id ITEM := FIND_ITEM('employees.job_id');
         x number;
    BEGIN
    IF NOT ID_NULL (group_id) THEN
              DELETE_GROUP (group_id);
         END IF;
              group_id := CREATE_GROUP_FROM_QUERY ('group','select name,TO_CHAR(id) job from cmn_jobs where job_type_id = 4720 ');
         x := POPULATE_GROUP (group_id);
         POPULATE_LIST (list_id, group_id);
         EXCEPTION
    WHEN NO_DATA_FOUND THEN
    null;
         END;
    That code worked very well and without any problem, but when I change the list item from combo box style to poplist style then the forms give that error:
    FRM-41337: Cannot populat the list from record group
    And an additional null/blanke element appears in the poplist with original element that come from RECORDGROUP.
    So can anyone help me to solve that problem please?

    First, how I can assign a default or initial value DYNAMICALLY to my poplist.Set the default-value to a parameter like :PARAMETER.MYPARAMETER then you can assign the desired default-value to the parameter.
    second, if I have popliste say X for example depend on another poplist say Y ,so when I put the code to populate popliste X on WHEN-LIST-CHANGED on popliste Y and make query then the >forms return FRM-40301 Query caused no records to be retrieved ,but when I have a copy for that code in WHEN-LIST-CHANGED and put it in WHEN-NEW-FORM-INSTANCE at the form >module the form work and returns records, so is it any error or exception in what I did.Can't answer that, you should check :SYSTEM.LAST_QUERY to see why the query does not returnany records.
    At the last, which better to put the code for popliste in PRE-FORM trigger at the form module or in WHEN-NEW-FORM-INSTANCE at the form module.I would use the PRE-FORM-trigger

  • Analytics report filtered on the current record id in a Siebel view

    Is it possible to have an analytics report integrated in a siebel view and for which the data would be filtered on the current record of this view, eg the current Account Id ?
    How to do that ?

    I found out the answer :
    technical note 661 on on Siebel Supportweb (metalink3) :
    "how to embed OBI requests in Siebel Business Application views, so that navigating among the records in the parent applet updates the child Analytics applet with context-appropriate content"

  • FRM-41337: Cannot pop list from record group

    If I update a record from a poplist and try to re-populate the list, i get this error. I've read you need to have a default or other values listed, unless it can accept NULL values. Well, it CAN accept NULL values, and required property is set to NO. I'd appreciate your help.

    On-line help says:
    ADD_LIST_ELEMENT restrictions:
    For a base table list with the List Style property set to Poplist or T-list, Form Builder does not allow you to add another values element when the block contains queried or changed records. Doing so causes an error. This situation can occur if you have previously used DELETE_LIST_ELEMENT or CLEAR_LIST to remove the other values element that was specified at design time by the Mapping of Other Values list item property setting.
    Note: The block status is QUERY when a block contains queried records. The block status is CHANGED when a block contains records that have been either inserted or updated.

  • Frm - 41337 - can not populate the list from record group

    Hi
    I have created a form with 4 combo boxes. And i am trying to populate the 4 combo boxes dynamically.
    Here is my table structure.
    BUS_FUNCTION VARCHAR2(500),
    SEQ NUMBER,
    STEP1 VARCHAR2(500),
    STEP2 VARCHAR2(500),
    STEP3 VARCHAR2(500),
    STEP4 VARCHAR2(500),
    KEYSTEP VARCHAR2(4000),
    OBJ_NAME VARCHAR2(500),
    SME VARCHAR2(50)
    In the fist combo box i am retriving bus_function and second seq and third step1.
    i wrote a trigger when_new_form_instance and i am calling a procedure from the trigger.
    here is my procedure code.
    PROCEDURE fp_get_list IS
    l_sql_text VARCHAR2(2000);
    BEGIN
    l_sql_text := 'SELECT bus_function,bus_function FROM TABS_BUS_FUNC';
    lp_populate_list('BUSFUNC.list22','rgcat2',l_sql_text);
    l_sql_text := 'SELECT TO_CHAR(SEQ),TO_CHAR(SEQ) FROM TABS_BUS_FUNC';
    lp_populate_list('BUSFUNC.BUS_FUNC','rgcat',l_sql_text);
    l_sql_text := 'SELECT step1,step1 FROM TABS_BUS_FUNC';
    lp_populate_list('BUSFUNC.list20','rgcat1',l_sql_text);
    END;
    Now the problem is i can able to get the values fro the first two colums. but the third column values are not populating.
    i am getting an error frm - 41337 - can not populate the list from record group.
    PLease help me in this.
    Thanks in advance,
    Raju

    I got answer
    i write a code in when-new-form-instance
    declare
    v_rg_id RECORDGROUP;
    v_return number;
    v_query varchar2(2000);
    outcome number ;
    begin
    v_rg_id := CREATE_GROUP_FROM_QUERY('RG_LIST','select Dname,To_char(Deptno) deptno from dept');
    v_return := POPULATE_GROUP(v_rg_id);
    POPULATE_LIST('emp.deptno', 'RG_LIST');
    end;
    but remember property of list item must be mapping of others value null and initial value null
    if ur problem not solve then tel me email, i ll send u fmb file

  • MessageChoice is not displaying the entire list of records

    I have created a page with a message choice and assigned a VO to it.
    The VO is retrieving 925 records, but the message choice is displaying only 200 records.
    Can we get the complete list of records using message choice.
    If not, is there any alternative.
    There is a fire action on this message choice.
    Thanks,
    divya

    Divya,
    LOV is the correct choice for displaying large data, but I suggest in your requirement you go with message choice only. You can safely turn the profile option FND: View Object Max Fetch Size from 200 to 1000.
    As in our case we always use it upto 1000 because ur client wanted only message choice.I haven't faced any performance issue in 1000, it may give performance issues at very high figures.
    --Mukul                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How to get Filtered external list data into infopath form

    Hello , 
    Below I am adding issue about filtered external list .
    I Created a external list which contains columns like projectuid and project name , I am filtering the list by adding a custom webpart and after filtering it displays only the filtered rows .
    I created a infopath form and i am using the same external list as data source . I am using the data source for an drop down list/ text box  .My requirement is to display only the filtered values in the drop down list but its displaying all the values
    present is in the external list .
    Is there any possibility to get only the filtered values into the drop down list ? 
    Indresh

    Actually, after thinking about it some more, you can filter the dropdown in InfoPath, but it depends on what you're filtering and whether that changes. If you want to filter it, you can go to the "control properties," then under "Entries," you can click
    the button on the right. Then "filter data" in the popup.
    As far as sending the information to a new list, you would have to use the "content organizer" under "manage site features" in your "site actions," or you would have to create a workflow in SP Designer.
    cameron rautmann

  • Record fetch size property hint

    Hi all,
    I'm using Oracle Forms Builder 10g and Oracle DB 11g. I have a LoV which selects about 150k rows. In fact in the DB the select * from <table> returns first 50 rows for about a second. My question is: What value to set for Record fetch size property to receive the first records faster because now it is loading about 20-30 seconds/which is unacceptable for me :) /. I checked docs for this property and if i increase it i suppose it will display rows faster?
    Thanks in advance,
    Bahchevanov.

    The records are composed of two columns, a code (5 characters) and a description (average size 25 characters). The average size of the record is then approx. 30 characters. From the documentation available in Forms:
        Also, the way in which the actual value is computed when a value of 0 is
        specified has changed. The actual value in this case is now
        0.5 M / total_record_size (i.e. sum_of_column_sizes, not max_column_size),
        but no more than 100 and no less than 20.  The coefficients (0.5 M, 100, and
        20) can be changed by setting these environment variables: 
        FORMS_COMPUTED_RGFS_DIVIDEND, FORMS_MAX_COMPUTED_RGFS,
        and FORMS_MIN_COMPUTED_RGFS.I believe that we are running with the default. Is this OK for this data set? Do we need to set the environmental variables listed above?
    Thanks,
    Thomas

Maybe you are looking for