www.Inmagic.com    Inmagic Forums    Inmagic Forums  Hop To Forum Categories  Scripting    Autopopulate
Go
New
Find
Notify
Tools
Reply
  
-star Rating Rate It!  Login/Join 
Ian
Posted
I’d like to be able to autopopulate a field ‘Ind_Oth’ based on the contents of another ‘loser’.

Loser can contain one or more values from CompanyOne, CompanyTwo, CompanyThree or CompanyFour.

If the ‘loser’ field contains CompanyOne, CompanyTwo or CompanyThree then ‘Industry’ is inserted into the ‘Ind_Oth’ field. If the ‘loser’ field contains CompanyFour then ‘Other’ is inserted onto the ‘Ind_Oth’ field.

I’ve got a script to do this, see below.


function onRecordSave()
{

var loserBox;
var IndustryOtherBox;
loserBox = Form.boxes("loser");
IndustryOtherBox = Form.boxes("Ind_Oth");

if((loserBox.content=="CompanyOne") || (loserBox.content=="CompanyTwo") || (loserBox.content=="CompanyThree"))
{
IndustryOtherBox.content = "Industry";
}
else if(loserBox.content=="CompanyFour")
{
IndustryOtherBox.content = "Other";
}

}


However, I’m having trouble extending the script to cope with multiple entries in the ‘loser’ field. For example if ‘loser’ contains CompanyOne or CompanyTwo or CompanyThree and CompanyFour I want ‘Both’ inserted into the ‘Ind_Oth’ field.

Can anyone help?
 
Posts: 9 | Location: London, UK | Registered: Fri March 15 2002Reply With QuoteEdit or Delete MessageReport This Post
Posted Hide Post
I have not looked deeply into your script. I only give you another solution to the same problem.
I have a reports database where we on the documents added to the database have Department name. But this Department also in our economic system have a number. I needed a field with that number. A document could be produced by authors from different departments. My way of solving the problem was to have a substitution list for the field with department number and through that getting the number added to the field.
I also had a requirement that a certain field should have the value "RCF". This argument could of cause be taken away.
My script is:
function onRecordSave()
{
var srcBoxDN1= Form.boxes("boxDN").content;
var srcBoxDN = Form.boxes("boxDEP");
var srcBoxDEP = Form.boxes("boxDEP");
var tgtBoxPL = Form.boxes("boxPL"); // control what is contained in the boxPL
if (srcBoxDEP && srcBoxDN1 =="") // be sure there is a box with the given name and the second box is empty
{
var srcTextDEP = srcBoxDEP.content;
if (srcTextDEP != "") // proceed only if the first box is nonempty
{
var tgtBoxDN = Form.boxes("boxDN");
if (tgtBoxPL.content == "RCF" && tgtBoxDN.content == "") // first box must contain entry “RCF” (means coming from our local research site) - second box must exist and be empty
Form.boxes("boxDN").content= srcTextDEP;
}
}

Through this script the things that is written in the Department field is copied into the Department number field, where a substitution list automatically writes in the Department number.


NEEngstrom
 
Posts: 40 | Location: Falun, Sweden | Registered: Tue September 17 2002Reply With QuoteEdit or Delete MessageReport This Post
 Previous Topic | Next Topic powered by eve community  
 

www.Inmagic.com    Inmagic Forums    Inmagic Forums  Hop To Forum Categories  Scripting    Autopopulate