Dear Dynamics folk,
I could use your assistance, if you would, to clean up this switch statement that I apparently seem unable to arrange successfully.
Up until line 24 was in place prior and is working as expected. My added code, line 26 and down, is causing me much grief.
We have a custom Inquiry page that is populated by all these computed columns and what I'm attempting to do is:
If the transportation mode of a contract is RAIL then I need to check the Equipment Owner. The Equipment Owner will have a value of 0 through 3 and it is based upon the value which I wish I select an additional string to addend to the column data.
private static server str GetPriceAndUom() { var contractLineView = tableStr(BRKContractLineView); var space = SysComputedColumn::returnLiteral(" "); List priceAndUom = new List(Types::String); var price = SysComputedColumn::cast( SysComputedColumn::cast( SysComputedColumn::returnField(contractLineView, identifierStr(BRKContractLine),fieldStr(BRKContractLine, Price)), "decimal(10, 4)"), "nvarchar(30)"); priceAndUom.addEnd(price); priceAndUom.addEnd(space); priceAndUom.addEnd(SysComputedColumn::returnField(contractLineView, identifierStr(BRKContractLine), fieldStr(BRKContractLine, PriceUnitOfMeasure))); priceAndUom.addEnd(SysComputedColumn::returnLiteral("\n")); priceAndUom.addEnd(SysComputedColumn::returnField(contractLineView, identifierStr(BRKContractLine), fieldStr(BRKContractLine, FreeOnBoard))); priceAndUom.addEnd(space); priceAndUom.addEnd(SysComputedColumn::returnField(contractLineView, identifierStr(BRKContractLine), fieldStr(BRKContractLine, Mode))); priceAndUom.addEnd(space); var priceType = SysComputedColumn::returnField(contractLineView, identifierStr(BRKContractLine), fieldStr(BRKContractLine, PriceType)); var estimated = SysComputedColumn::returnLiteral("EST"); var firm = SysComputedColumn::returnLiteral("FIRM"); priceAndUom.addEnd(SysComputedColumn::if(SysComputedColumn::equalExpression(priceType, SysComputedColumn::returnLiteral("ESTIMATED")), estimated, firm)); priceAndUom.addEnd(SysComputedColumn::returnLiteral("\n")); var mode = SysComputedColumn::returnField(contractLineView, identifierStr(BRKContractLine), fieldStr(BRKContractLine, Mode)); var equipmentOwner = SysComputedColumn::cast(SysComputedColumn::returnField(contractLineView, identifierStr(BRKShippingScenario), fieldStr(BRKShippingScenario, EquipmentOwner)), "nvarchar(30)"); var prv = SysComputedColumn::returnLiteral("PRV"); var rr = SysComputedColumn::returnLiteral("RR"); var shp = SysComputedColumn::returnLiteral("SHP"); var vnd = SysComputedColumn::returnLiteral("VND"); Map valueMap = new Map(Types::String,Types::String); valueMap.insert("0", prv); valueMap.insert("1", rr); valueMap.insert("2", shp); valueMap.insert("3", vnd); var tackOnEquipmentOwner = SysComputedColumn::switch( equipmentOwner, valueMap, "NO MATCH"); priceAndUom.addEnd(SysComputedColumn::if(SysComputedColumn::equalExpression(mode, SysComputedColumn::returnLiteral("RAIL")), tackOnEquipmentOwner, "MODE NOT RAIL")); return SysComputedColumn::addList(priceAndUom); }
Hoping it's something simple, and probably looking right at me, but I've been messing with this since Friday and about to pull my hair out! Many thanks.