json formatting – How to display past list items related to a column value?

I have the following SharePoint list in which the “Participant” columns are text values (names of people) and each item in this list is a training event. “Evenement” is the type of training and “Jour” means day of the training.

What I need to do is whenever someone hovers on the name of a participant – I need their past training events to show.
For example if “Participant 1” is Alpha and his “Jour 1” is on 11-05-2021 then “Jour 2” is on 12-05-2021 and “Jour 3” is 13-05-2021 and finally “Jour 4” is 14-05-2021. I need all this information to show on a hovercard if possible?

I am not sure if this makes complete sense or not and if it’s even possible but any guidance would be appreciated, thank you in advance to anyone who replies and please be advised I’m only starting with JSON .

Sharepoint List Preview

Cognito Forms: Selecting Individual Items From an Array

I have created an array, using the .Split() functionality, I would like to now reference each item (it I believe) in that array, specifically.

How do I achieve that?


The rest of this you don’t need to read, but I’ll try to provide more information.

I am now going to use an example of something that I might like to do, this is not literally all I want to do.

So. Let’s say a user has input the following data in to the ‘Inputta‘ field:

aaa#bbb#ccc#ddd#eee#fff

Now, in the ‘Arraya‘ field, I have:

Inputta.Split("https://webapps.stackexchange.com/#")

Let’s say I would like to select the “ddd” entry in that array, how would I do that?

I’ve tried using the .Where() functionality, eg: “.Where(ItemNumber = 4)“, but even if that did work (it doesn’t), it would be no use for if I need to be iterative.

I’ve tried to play with the .Select() functionality, but that’s not helpful, either, as I can’t find decent information on how it even works.


So, on to that iterative tip, to build on this example, I have a secondary requirement of the form, which is to pick an item from the array from an incremented integer.

We’ll imagine I know how to increment an integer, and have that information already, either in a separately generated .Split() field, or as an integer calculation in a Repeating Section.

How would I use the integer to find the array entry in the ‘Arraya‘ field?

Basically, how would I select item 1 (from the second array), then item 2, etc?

This isn’t a separate question, I’m just explaining further the requirement.


As an addendum, I’d love to know how to create an array of incremental integers leading to a pre-determined max number. 😉


For the record, I have StartPaged this thoroughly.

  1. I can’t find a full reference chart for the functions available anywhere online.
  2. The list on CF only lists a subset of the available functions (for example, the .Select() array functionality is not listed)
  3. Everywhere else appears to handle other specific functions.

None of that is stated to cast any disdain anywhere, purely to indicate that I have looked, perhaps my StartPage Fu is just not that strong. Either way, apologies for asking here.

dynamic programming – How to get max amount of items in Knapsack problem

I’m trying to find max possible amount of weights which sum <= target sum.
Example:

weights = (3, 2, 5, 2, 1, 1, 3), target_sum = 10
3, 2, 1, 3, 1 -- (sum = 10) correct items because has max items
5, 2, 3 -- (sum = 10) not max amount of items

I’ve done the DP solution which can find max possible sum and max possible amount of items (which sum <= target sum).
But I’m really stuck to get the max possible items which sum <= target from DP.

I know how to get the any items. So I did one trick with sorting.
But I’m trying to find a way how it could be done without sorting.

Python code:

def max_subset_sum(ws, target_sum):
    n = len(ws)
    k = target_sum

    dp = ((0) * (k + 1) for _ in range(n + 1))
    count = ((0) * (k + 1) for _ in range(n + 1))

    for i in range(1, n + 1):
        for j in range(1, k + 1):
            curr_w = ws(i - 1)
            if curr_w > j:
                dp(i)(j) = dp(i - 1)(j)
                count(i)(j) = count(i - 1)(j)
            else:
                tmp = round(dp(i - 1)(j - curr_w) + curr_w, 2)
                if tmp >= dp(i - 1)(j):
                    dp(i)(j) = tmp
                    count(i)(j) = count(i - 1)(j - curr_w) + 1
                else:
                    dp(i)(j) = dp(i - 1)(j)
                    count(i)(j) = count(i - 1)(j)

    return get_items(dp, k, n, ws)


def get_items(dp, k, n, ws):
    # The trick which allows to get max amount of items if input is sorted
    start = n
    while start and dp(start)(k) == dp(start - 1)(k):
        start -= 1


    res = ()
    w = dp(start)(k)
    i, j = start, k
    while i and w:
        if w != dp(i - 1)(j):
            res.append(i - 1)
            w = round(w - ws(i - 1), 2)
            j -= ws(i - 1)
        i -= 1

    return res

if __name__ == '__main__':
    # 3 + 2 + 1 + 3 + 1 == 10 (preferable result set)
    # 5 + 2 + 3 == 10 (not max amount of items)
    xs = (3, 2, 5, 2, 1, 1, 3)

    indexes = max_subset_sum(xs, 10)
    result1 = (xs(i) for i in indexes)
    print(result1)  # (5, 2, 3)

    # But in case if we have sorted amount:
    xs_sorted = sorted(xs)
    indexes = max_subset_sum(xs_sorted, 10)
    result2 = (xs_sorted(i) for i in indexes)
    print(result2)  # (3, 3, 2, 1, 1)

Also, I have weird attempt to get max amount of items.
But it’s produces incorrect result which sums to 9: (3, 1, 1, 2, 2)

def get_items_incorrect(dp, count, k, n, ws):
    start = n

    res = ()
    w = dp(start)(k)
    i, j = start, k
    while i and w:
        # while dp(i)(j) < ws(i - 1):
        #     i -= 1
        while ws(i - 1) > j:
            i -= 1
        if i < 0:
            break

        max_count = count(i)(j)
        max_count_i = i

        while i and w == dp(i - 1)(j):
            if count(i - 1)(j) > max_count:
                max_count = count(i - 1)(j)
                max_count_i = i - 1
            i -= 1

        res.append(max_count_i - 1)
        w = round(w - ws(max_count_i - 1), 2)
        j -= ws(max_count_i - 1)

        i = max_count_i - 1

    return res

For convenience, dp and count for given example:

ws: (3, 2, 5, 2, 1, 1, 3), target_sum: 10
     0, 1, 2, 3, 4, 5, 6
dp:
0: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
1: (0, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3)
2: (0, 0, 2, 3, 3, 5, 5, 5, 5, 5, 5)
3: (0, 0, 2, 3, 3, 5, 5, 7, 8, 8, 10)
4: (0, 0, 2, 3, 4, 5, 5, 7, 8, 9, 10)
5: (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
6: (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
7: (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)

count:
0: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
1: (0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1)
2: (0, 0, 1, 1, 1, 2, 2, 2, 2, 2, 2)
3: (0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 3)
4: (0, 0, 1, 1, 2, 2, 2, 2, 2, 3, 3)
5: (0, 1, 1, 2, 2, 3, 3, 2, 3, 3, 4)
6: (0, 1, 2, 2, 3, 3, 4, 4, 3, 4, 4)
7: (0, 1, 2, 1, 2, 3, 3, 4, 4, 5, 5)

Sorry for such long read & thank you for any help!

SQL JOIN QUERY with more than one items in common: Find the franchise pairs that operate together in more than one location

I have a table called dfmt that lists the location, revenue and franchise. I want to find the franchise pairs that operate together in more than one location.

Some sample data

So far, I have a query that finds the franchise pairs that operate in the same location:

select T1.fr, T2.fr2 from dfmt T1 join (select fr as fr2, loc as loc2 from dfmt) as T2 on T1.fr < T2.fr2 and T1.loc = T2.loc2 order by loc;

I do not know how to go from here to find the franchise pairs that operate together in only more than one location.

Another query that may be useful that Finds the franchise that generates the maximum revenue in more than one location.

select fr, count(*) from tst2 where rev in (select max(rev) from tst2 group by loc) group by fr having count(*)>1;
enter code here

How to delete calendar items from SharePoint online calendar list using PowerShell?

Download the SP online management shell.

You can either go with the default SP online PowerShell commands or the PnP way. To get the PnP commands, install the PnP module by invoking

Install-Module SharePointPnPPowerShellOnline

And then connect to your site using

Connect-PnPOnline –Url https://yoursite.sharepoint.com –Credentials (Get-Credential)

Now, to retrieve all the calendar items, tweak the following command:

$listItems = Get-PnPListItem -List Calendar -Query "<View><Query><Where><Eq><FieldRef Name="EventDate" /><Value Type="DateTime"><Today /></Value></Eq></Where></Query></View>"

The above command lists all the events for today. Add your conditions for the date fields to get your collection.

I have not tried retrieving recurring events before, so I believe you might need to play with the columns “RecurrenceID”, “fRecurrence” and(or) “RecurrenceData”. Check this article for more details.

Now when you are sure that all the retrieved items are as per the condition and this is exactly what you would like to copy or delete, then add a for loop to copy or delete them.

foreach($item in $listItems) {
        #Create object
    $itemVal = @{       
        'Title' = $item('Title')
        ...........
        .........
    }
    Add-PnPListItem -List 'newCalendarlist' -Values $itemVal -ContentType "Item"
}

And for the delete command, get the list item ids and pass it on in a for loop.

Remove-PnPListItem -List "Demo List" -Identity "1"

event observer – Not able to get parent_item_id for cart items retrieved from Order – Magento 2.3.5

I’m trying to get parent_item_id but it is returning null for all simple child products.

    $order = $observer->getEvent()->getOrder();
    $items = $order->getAllVisibleItems();
    foreach ($items as $item) {
            $itemsData() = (
                'name' => $item->getName(),
                'sku' => $item->getSku(),
                'quote_item_id' => $item->getQuoteItemId(),
                'parent_item_id' =>$item->getParentItemId(),
                'qty_ordered' => $item->getQtyOrdered(),
                'product_type' => $item->getProductType(),
                'weight' => $item->getWeight(),
                'price' => $item->getPrice()
            );        
    }

I’m getting all item attributes in my $itemsData array except parent_item_id, though I’ve 4 children of a Bundle product and 1 child of a configurable product in Cart.

I’m doing it in sales_order_place_before observer. I tried getAllItems() and getItems() as well but no luck. Also confirmed from database, parent_item_id exists there for quote_item_id, but just not able to retrieve via getter method.

loop – Portfolio items created indefinitely from external API. Every time different number

I am trying to make new portfolio item for every json item from external api. I am working on WordPress and placed my code in functions.php of the theme used. When i run my code, it creates portfolio items more than necessary. The items seem to randomly get duplicated even tho i have made validation statement and made sure that each post lug is unique. I want it to stop when the array in json file finishes. Unfortunately I can’t share the api link because it is not supposed to be open-source. It consists of one page. $model and $results get correct info. I am new to these WP functions and API thing and got really confused at this point. Hope someone can help me out!:

add_action('wp_ajax_nopriv_get_3dmodels_from_api', 'get_3dmodels_from_api');
add_action('wp_ajax_get_3dmodels_from_api', 'get_3dmodels_from_api');

function get_3dmodels_from_api(){
    
    $results = wp_remote_retrieve_body(wp_remote_get('<api-url-here>',  array(
        'timeout'     => 120,
        'httpversion' => '1.1',
    ) ) );  
    
    $results = json_decode($results);
    //print_r($results);

    
    foreach($results->scenes as $model) {
        
        $model_slug = sanitize_title($model->name. '-' . $model->id);
        
        $existing_model = get_page_by_path($model_slug, 'OBJECT', 'portfolio');

        if ($existing_model === null) {

            $inserted_model = wp_insert_post((
                'post_name'=> $model_slug,
                'post_title'=> $model_slug,
                'post_type'=> 'portfolio',
                'post_status' => 'publish',
            ));
            
            if (is_wp_error($inserted_model)) {
                return false;
            }
        
            $fillable = (
                'field_605dcef7001bc' => 'name',
                'field_605dcf01001bd' => 'description',
                'field_605dcf09001be' => 'category',
                'field_605dcf13001bf' => 'preview',
            );
            
            foreach($fillable as $key => $name) {
                $model_content = $model->$name;
                
                if ($name == 'preview') {
                    $model_content = '<img src="https://wordpress.stackexchange.com/. $model->$name ."" alt="">';
                }
                
                update_field($key, $model_content, $inserted_model);
            }
        } 
wp_remote_post(admin_url ('admin-ajax.php?action=get_3dmodels_from_api'), (
        'blocking' => false,
        'sslverify' => false,
    ));
}

Thank you!

2013 – Unable to add/remove items in Global and current navigation in SharePoint online

I am trying to add items in Global Navigation in a SharePoint online site.

When I goto site settings and Navigation under look and feel (/_layouts/15/AreaNavigationsettings.aspx), I see empty Global Navigation and Current Navigation.

When I add something (Link & Headings) under it and click ok, it is not getting saved. Even when I click on edit links on left navigation and add a link and save it, it is not getting saved.

Not sure what the issue is, any guidance is appreciated. TIA

spells – Can a creature forego its attended magic item’s saving throws?

Some PCs are fighting other mind-controlled PCs. The wizard casts mage’s disjunction to end the mind control effect. This works, but, in addition to doing that, the spell says that

each permanent magic item must make a successful Will save or be turned into a normal item for the duration of this spell [i.e. 1 min./level]. An item in a creature’s possession uses its own Will save bonus or its possessor’s Will save bonus, whichever is higher. If an item’s saving throw results in a natural 1 on the die, the item is destroyed instead of being suppressed.

With this in mind, can a creature that’s attending a magic item voluntarily give up the magic item’s saving throw against the disjunction so that the magic item is automatically suppressed for some minutes? Or must the magic item always attempt the saving throw—in such cases, always risking its existence to avoid a few minutes of inactivity? Or is there another option?

gui design – Best way to move items in a list when the list is paginated

I have a paginated list where the user drags and drops items to change the order. This list is paginated, so when the length of the list is longer than the page there is no clear way to move items outside of the current page. Is there a design pattern I could use?

The application is an Angular app with a UI very similar to this. The lists have a considerable number of items so due to performance issues we are adding pagination to it, which is causing a lot of UI problems.