web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

If else Plugin

(0) ShareShare
ReportReport
Posted on by

Hi all

I'm not sure if it's a lack of sleep coffee or something but i seem to be missing something with in some code. Basically i'm trying to build a price list by coping another but while it's coping i want it to check the productid and if it matches i want it to put in a certain price. Can some kind person have a little gander of the code below and point out my simple mistake

for (int index = 0; productPriceLevelList.Entities != null && index < productPriceLevelList.Entities.Count; index++)
{
Entity newProductPriceLevelEntity = new Entity("productpricelevel");
newProductPriceLevelEntity["pricelevelid"] = new EntityReference("pricelevel", newPriceLevelId);
//string productidtext = productPriceLevelList.Entities["Product","productid"];
newProductPriceLevelEntity["productid"] = productPriceLevelList.Entities[index]["productid"];
string Price3000 = ManholePrice3000.Get<string>(executionContext);
newProductPriceLevelEntity["uomid"] = productPriceLevelList.Entities[index]["uomid"];
string prodidse = newProductPriceLevelEntity["productid"];


//prodidcon = Convert.ToString(productidtext);

if (prodidse == r1)
{
costamount = 1000;
goto endt;
}
else if (prodidse == "R1050750N")
{
costamount = 2000;
goto endt;
}
else
{
costamount = 99;
;
}
endt:

newProductPriceLevelEntity["amount"] = new Money(costamount);
service.Create(newProductPriceLevelEntity);


}

Many Thanks

Dan

*This post is locked for comments

I have the same question (0)
  • Verified answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

    Try to replace line

    string prodidse = newProductPriceLevelEntity["productid"];

    with line

    string prodidse = newProductPriceLevelEntity.GetAttributeValue<EntityReference>("productid").Name;

  • Community Member Profile Picture
    on at

    You my friend are a star it work brilliant

    Many Thanks

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Varsha deshpande Profile Picture

Varsha deshpande 5

#2
JS-09031509-0 Profile Picture

JS-09031509-0 3

#3
Ciprian  P Profile Picture

Ciprian P 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans