lunedì 20 gennaio 2014

AX 2012 - SSRS valore assente per un nuovo parametro

Quando aggiungiamo un parametro al form di lancio dei report in AX 2012, può capitare che questo valore al lancio sia nullo, ma se non gestiamo questa eventualità (impostando le proprietà adeguate lato Visual Studio) allora avremo il seguente messaggio di errore:

The 'ParameterName' parameter is missing a value


In questo caso impostare le giuste proprietà in Visual Studio:

Allow Blank       True
Nullable            True
 nel parametro avente il problema (ed eseguire il deploy) potrebbe non bastare!

In questo caso occorre agire come brillantemente segnalato in questo blog, dove segnala i vari metodi per far "sentire" questa modifica:
blog con i metodi

Method I.
Force the update of the properties by renaming the parameter
1. Open the report for editing in Visual Studio.
2. Expand the Parameters node and rename the affected parameter to ParameterName1.
3. Set Allow Blank and Nullable to True if not already set.
4. Deploy the report.
5. Rename the parameter back to ParameterName.
6. Deploy the report.

Method II.
Recreate the parameter in Visual Studio and set the properties as required before deploying the report
1. In AOT, expand the SSRS Reports node, expand the Reports node and locate the report.
2. Right click on the report and select Delete. This will remove all customizations to the report from the current model/layer so make sure you create a backup if you think you might want to return to them.
3. Right click on the report and select Deploy element. You should now be at the point where you did not receive this error.
4. Open the report for editing in Visual Studio and refresh the dataset. The parameter will be created under theParameters node. Do not deploy the report at this point.
5. Set Allow Blank and Nullable to True.
6. Deploy the report.

Method III.
Modify the properties of the parameter editing the report in the Reporting Services Report Manager

1. Open the report for editing in Visual Studio.
2. Expand the Parameters node and locate the affected parameter.
3. Set Allow Blank and Nullable to True if not already set.
4. Deploy the report.
5. Open Reporting Services Report Manager, in the Parameters properties page of the report, verify that Has defaultand Null check boxes are selected for the affected parameter.
6. Press Apply to save any changes.

venerdì 3 gennaio 2014

AX 2012 - Default dimension

In questo post vediamo come gestire le dimensioni finanziare nelle anagrafiche cliente/fornitore. Il job sottostante scrive nella defualt dimension "CLIENTE" il valore del custAccount:

 static void CreateDefaultDimension(Args _args)  
 {  
   DimensionAttributeValueSetStorage  valueSetStorage = new DimensionAttributeValueSetStorage();  
   DimensionDefault          result;  
   CustTable        custTable = CustTable::find('‪‪‪I01-000001',true);  
   int           i;  
   DimensionAttribute   dimensionAttribute;  
   DimensionAttributeValue dimensionAttributeValue;  
   container        conAttr = ["CLIENTE"]; //nome della dimensione  
   container        conValue = ["I01-000001"]; //valore da inserire  
   str           dimValue;  
   /* per evitare l'hard code 'CLIENTE' possiamo cercare nella tabella dimensionAttribute per   
   backEntityType che è un table num. Nel caso cliente tableNum sarà = tableNum(DimAttributeCustTable)  
   mentre nel caso fornitori tableNum(DimAttributeVendTable)*/  
   for (i = 1; i <= conLen(conAttr); i++)  
   {  
     dimensionAttribute = dimensionAttribute::findByName(conPeek(conAttr,i));  
     if (dimensionAttribute.RecId == 0)  
     {  
       continue;  
     }  
     dimValue = conPeek(conValue,i);  
     if (dimValue != "")  
     {  
       dimensionAttributeValue =  
           dimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttribute,dimValue,false,true);  
       valueSetStorage.addItem(dimensionAttributeValue);  
     }  
   }  
   result = valueSetStorage.save();  
   ttsBegin;  
   custTable.DefaultDimension = result;  
   custTable.doUpdate();  
   ttsCommit;  
 }  
Prima dell'esecuzione del job:


Dopo l'esecuzione:


Una diversa soluzione, un pò più complessa l'ho trovata quì