function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

How do I get the Id from the list?

Here is my code:

public void selectProductsByTariff(){
        system.debug( 'Start ' +  myOpportunity.Id );
      tariffName = System.currentPageReference().getParameters().get('Tariff');
        system.debug( 'Tariff: ' +tariffname);
        listTariff_Bundles = [SELECT Name, (SELECT Id, Name, Product__c FROM Product2Tariff__r) from Tariff_Bundles__c WHERE Name = :tariffname LIMIT 1];
        for (Tariff_Bundles__c master : listTariff_Bundles) {
           System.debug('Here is an ObjectMaster record: '+master);
          for (Product2Tariff__c detail : master.Product2Tariff__r) {
              object productId = detail.get('Id');
              myProduct = [SELECT Id, Name from Product2 where Id = :productId];  (invalid bind expression type of object for column of type Id)
            System.debug('Here is an ObjectDetail record: '+productName);

Please help me!!
Change line 
object productId = detail.get('Id');

Id productId = detail.Id;
Thank you!
Has worked.
Can you please explain to me how from can create a list?

Thank you