You need to sign in to do that
Don't have an account?
Jyosi jyosi
Map<Id,Set<Id> Syntax
Map<Id,Set<Id>> NoIFC_Product_Map= new Map<Id,Set<Id>();
Set<Id> NoIFC_Product= new set<id>();
for(product2 Products:AllProducts_Query)
{
if(Products.Test__c==true)
{
NoIFC_Product.add(Products.Id);
NoIFC_Product_Map.Put(Products.Id,NoIFC_Product);
for(SampleLineItemExt sliExt : sampleLineItemExtList) {
Sample_Line_Item__c sli = sliExt.sampleLineItem;
if(sli.Id != null) { // Product_Number__c replaced by Product_No__c
if((sli.Product_No__c == null )
&& (sliExt.iqty == null || sliExt.iqty.equals(''))
&& (sli.Unit_Of_Measure__c == null || sli.Unit_Of_Measure__c.equals(''))
) {
delSliSet.add(sliExt.sampleLineItem.Id);
}
}
if((sli.Product_No__c != null )&& (sliExt.iqty != null && !sliExt.iqty.equals('')) && (sli.Unit_Of_Measure__c != null && !sli.Unit_Of_Measure__c.equals(''))) {
sli.Quantity__c = Integer.valueOf(sliExt.iqty);
if(sli.Sample__c == null)
sli.Sample__c = sampleRecord.Id;
sli.Product_No__c=NoIFC_Product_Map.get(sli.Product_No__c); I want to access the id and get the set of ids,
I get the error Illegal assignment from Set<Id> to Id when i use the Map.Get(Id).
Can you please help me out.
newSli.add(sli);
}
Thanks
Regards,
Jyo
}
Set<Id> NoIFC_Product= new set<id>();
for(product2 Products:AllProducts_Query)
{
if(Products.Test__c==true)
{
NoIFC_Product.add(Products.Id);
NoIFC_Product_Map.Put(Products.Id,NoIFC_Product);
for(SampleLineItemExt sliExt : sampleLineItemExtList) {
Sample_Line_Item__c sli = sliExt.sampleLineItem;
if(sli.Id != null) { // Product_Number__c replaced by Product_No__c
if((sli.Product_No__c == null )
&& (sliExt.iqty == null || sliExt.iqty.equals(''))
&& (sli.Unit_Of_Measure__c == null || sli.Unit_Of_Measure__c.equals(''))
) {
delSliSet.add(sliExt.sampleLineItem.Id);
}
}
if((sli.Product_No__c != null )&& (sliExt.iqty != null && !sliExt.iqty.equals('')) && (sli.Unit_Of_Measure__c != null && !sli.Unit_Of_Measure__c.equals(''))) {
sli.Quantity__c = Integer.valueOf(sliExt.iqty);
if(sli.Sample__c == null)
sli.Sample__c = sampleRecord.Id;
sli.Product_No__c=NoIFC_Product_Map.get(sli.Product_No__c); I want to access the id and get the set of ids,
I get the error Illegal assignment from Set<Id> to Id when i use the Map.Get(Id).
Can you please help me out.
newSli.add(sli);
}
Thanks
Regards,
Jyo
}
set<Id> temp = NoIFC_Product_Map.get(sli.Product_No__c);
Then you have to assign the value from this set to sli.Product_No__c.
sli.Product_No__c.=temp
Thanks for help
Regards,
Jyo
Please find the corrected program.
Also added my comment whereever I modified with.
//MD - Modified
Please do let me know if it helps.
Regards,
Mahesh
As you are getting the set of Ids, what do you want to achieve here, if you can explain the requirement, it will be easy otherwise we can assign 0 index value into it using below:
sli.Product_No__c = (new list<Id>(tempNoIFC_Prod) )[0] );
or else
for (Id idVal : tempNoIFC_Prod) {
sli.Product_No__c= idVal;
break;
}
Regards,
Mahesh
But me need to assign the set of values to Sli.product__C=tempNoIFC_Prod and that values to newSli list .How can this can be achevied.
Regards,
Mahesh
set<Id> temp = NoIFC_Product_Map.get(sli.Product_No__c);
for (Id idpno : temp) {
sli.Product_No__c= idpno+',';
}
If needed how can achevie how this?
Thanks
Regards,
Jyo
If it is Master-Details then you can assign only one value to it.
Regards,
Mahesh
I have sample ,Sample_line_item object .In sample _Line item object we have a lookup relation to product2 .
There is one field test__c on product ,
suppose if the user selects prodcuts A=true,B=false,C=false, A B,C,
I need to insert A B C ,B,C in the sample_line_item.
Thanks
Regards,
Jyo
LstProduct=[Select id,Name,Test__c from Product2 where Id=:IFU_DUP and BOM__c=false];
I am passing two identicals ids aganist the product ,I want the query to retun the list twice.
LstProduct=[Select id,Name,Test__c from Product2 where Id=:IFU_DUP and BOM__c=false];
System.debug(' LstProduct>>> '+LstProduct.size()+' >>>>> '+LstProduct);
LstProduct>>> 3 >>>>> here the list should be 6 but i am getting 3 values i know i am passing the same ids.
Is there any way the the list will loop to get all the records in the query.
Thanks for the help.
Regards,
Jyo
list<Product2> duplicateProds = new list<Product2>();
duplicateProds.addall(listProd1);
duplicateProds.addall(listProd2);
But I am not sure why you need same records twice in the list.
Can you paste the actual requirement and your exists trigger / class / vf page so that we can able to understand.
Regards,
Mahesh