﻿<?xml version="1.0" encoding="utf-8"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><title>Intersoft Community - WebScheduler - How do I create a resource and select it on a custom editing form when the user saves?</title><link>http://www.intersoftsolutions.com/Community/WebScheduler/How-do-I-create-a-resource-and-select-it-on-a-custom-editing-form-when-the-user-saves/</link><description /><generator>http://www.intersoftsolutions.com</generator><language>en</language><copyright>Copyright 2002 - 2015 Intersoft Solutions Corp. All rights reserved.</copyright><ttl>60</ttl><item><title>How do I create a resource and select it on a custom editing form when the user saves?</title><link>http://www.intersoftsolutions.com/Community/WebScheduler/How-do-I-create-a-resource-and-select-it-on-a-custom-editing-form-when-the-user-saves/</link><pubDate>Wed, 28 Oct 2009 08:54:21 GMT</pubDate><dc:creator>David</dc:creator><description>&lt;p&gt;Glenn,&lt;/p&gt;
&lt;p&gt;   Well that makes sense! I did not realize that was asynchronous. I made some slight changes, to call the original function only after the resource is set in the timeout function, or otherwise only if the resource is already selected.&lt;/p&gt;&lt;pre&gt;var currentItemResourceCount;

function wbSave_OnClick() {
    var wr = ISGetObject("wcResources");

    //create and add a new resource if one is not selected (an existing event)
    if (wr.Value == "") {
        currentItemResourceCount = wr.Rows.length;
        ISGetObject("wiResourceName").SetValueData("New Resource");
        ISGetObject("wcResourcesColor").SetSelectedIndex(0);
        ISGetObject("wiRLocation").SetValueData("N/A");
        ISGetObject("wiRDescription").SetValueData("New Resource");
        WS_OnSaveResource();

        wr.UpdateUI();
        SetLatestResource();
    } &lt;span style="color: #ff0000"&gt;else&lt;br /&gt;        WS_OnSave();
&lt;/span&gt;
    return true;
}

function SetLatestResource() {
    var wr = ISGetObject("wcResources");
    if (wr.Rows[currentItemResourceCount] != null) {
        //Now select the new row
        ISGetObject("wcResources").Rows[wr.Rows.length - 1].Select();

        //call original function
        &lt;span style="color: #ff0000"&gt;WS_OnSave();&lt;/span&gt;
    }
    else {
        setTimeout(function() { SetLatestResource(); }, 10);
    }
}&lt;/pre&gt;
&lt;p&gt;Thanks so much for your help. It is really great to have this kind of flexibility with your control.&lt;/p&gt;</description></item><item><title>How do I create a resource and select it on a custom editing form when the user saves?</title><link>http://www.intersoftsolutions.com/Community/WebScheduler/How-do-I-create-a-resource-and-select-it-on-a-custom-editing-form-when-the-user-saves/</link><pubDate>Tue, 27 Oct 2009 23:35:11 GMT</pubDate><dc:creator>Glayaar</dc:creator><description>&lt;p&gt;In your code, you are using UpdateUI function which is asynchronous and trying to set the combo to the newly added item. Since UpdateUI function is asynchronous, it will take some time to update the UI to relfect the changes. You will need to set some timeout to wait for the WebCombo to refresh. Here is the modified snippet:&lt;br /&gt;&lt;/p&gt;&lt;pre&gt;var currentItemResourceCount;&lt;br /&gt;&lt;br /&gt;function wbSave_OnClick() {    var wr = ISGetObject("wcResources");    //create and add a new resource if one is not selected (an existing event)
    if (wr.Value == "") {
        &lt;span style="color: rgb(255, 0, 0); "&gt;currentItemResourceCount = wr.Rows.length;&lt;/span&gt;
        
        ISGetObject("wiResourceName").SetValueData("New Resource1");
        ISGetObject("wcResourcesColor").SetSelectedIndex(0);
        ISGetObject("wiRLocation").SetValueData("N/A");
        ISGetObject("wiRDescription").SetValueData("New Resource1");
        WS_OnSaveResource();
        //Now select the new row
        wr.UpdateUI();
        &lt;span style="color: rgb(255, 0, 0); "&gt;SetLatestResource();&lt;/span&gt;
    }
    //Now call original function and return
    WS_OnSave();
    return true;
}
function SetLatestResource() {
    var wr = ISGetObject("wcResources");
    if (wr.Rows[currentItemResourceCount] != null) {
        ISGetObject("wcResources").Rows[wr.Rows.length - 1].Select();
    }
    else {
        setTimeout(function() { SetLatestResource(); }, 10);
    }
}&lt;/pre&gt;
&lt;p&gt; &lt;/p&gt;</description></item><item><title>How do I create a resource and select it on a custom editing form when the user saves?</title><link>http://www.intersoftsolutions.com/Community/WebScheduler/How-do-I-create-a-resource-and-select-it-on-a-custom-editing-form-when-the-user-saves/</link><pubDate>Fri, 23 Oct 2009 10:22:41 GMT</pubDate><dc:creator>David</dc:creator><description>&lt;p&gt;I would like to control the resources on the custom editing form in code including creating the resource and choosing it for the user. Can someone provide a sample for how to do it? I have tried something like the following... First change the OnClientClick of the save button to my own function that then calls the original function when finished.&lt;/p&gt;&lt;pre&gt;function wbSave_OnClick() {
    var wr = ISGetObject("wcResources");

    //create and add a new resource if one is not selected (an existing event)
    if (wr.Value == "") {
        ISGetObject("wiResourceName").SetValueData("New Resource");
        ISGetObject("wcResourcesColor").SetSelectedIndex(0);
        ISGetObject("wiRLocation").SetValueData("N/A");
        ISGetObject("wiRDescription").SetValueData("New Resource");
        WS_OnSaveResource();

        //Now select the new row
        wr.UpdateUI();
        wr.Rows[wr.Rows.length - 1].Select();
    }

    //Now call original function and return
    WS_OnSave();
    return true;
}&lt;/pre&gt;
&lt;p&gt;The new row appears in the WebCombo, but I cannot seem to see it in the rows collection right after creating a new one. Is there some other way of getting the resources WebCombo to repopulate?&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;</description></item></channel></rss>