PCF Component save data to SingleLineText - reactjs

i have a small problem:
I coded a checklist for MS Dynamics 365 as a pcf component.
Now I have the problem that i can't save the data.
The Checklist's data is stored in a JSON format.
I want to store this JSON in the entity.
This is my property.
<property name="saveCheckList" display-name-key="datom_saveCheckList" description-key="Property_Desc_Key" of-type="SingleLine.TextArea" usage="bound" required="true" />
Can you please tell me how I store the data. Thank you!
If you need more informations do't worry to ask.

you need to ensure that the PCF method getOutputs returns the data being stored in your component code. For example, we store a JSON in the control and if we want the control to tell the Dynamics 365 to save the actual data, we use it like this:
/**
* It is called by the framework prior to a control receiving new data.
* #returns an object based on nomenclature defined in manifest, expecting object[s] for property marked as “bound” or “output”
*/
public getOutputs(): IOutputs {
// Our method to retrieve JSON.
let data = this.priceIndexationData.getData();
// And we tell the framework to save the JSON to bound property (declared in control's manifest)
return { priceIndexationData: data }
}
Manifest line of declaring the "priceIndexationData" in our case:
<property name="priceIndexationData" display-name-key="Price Indexation Data" description-key="ken_priceindexationdata field value." of-type="Multiple" usage="bound" required="true" />

Related

How to handle incremental fetches from Salesfore and Database Component

I have a salesforce query which returns contact information. I need to save the data in 2 tables. In the first table I have to store some metadata about the contacts in an intermediate state. I then get the auto-generated metadata table ID from the metadata saved and apply it to every contact. I then have to save the contact data into a database table and then finally update the contacts metadata to its final state. The problem is that there is a lot of data so I have to include a fetch size when performing this process. What I want to achieve should be something like this, please note this is only what I am looking to achieve. How can I know that the fetch contacts is complete, so that I can save the final state? How can I structure the flow for transactions?
Ideally, I would like to pass the ConsumerIterator to a Java component where I can easily control the process. Can I pass a reference of the ConsumerIterator to a Java component for example? If I can how can I do so?
<sfdc:query fetchSize="100" config-ref="sfdc-connector"
query="dsql:SELECT Id, Account.Id,
Account.Name, Account.PersonEmail, Account.LastName From Contact" />
dw:transform-message metadata:id="d1f6ab4f-4b40-4e30-ae" doc:name="trnsfm">
<enricher target="variable:metaInfo">
<flow-refname="getContactMetadata"/>
</enricher>
<dw:set-payload><![CDATA[%dw 1.0
.//Rest of transformer
<db:insert config-ref="MySQL_Configuration" doc:name="Save Metatdata">
...
</db:insert>
<db:insert config-ref="MySQL_Configuration" doc:name="Save contacts">
....
<db:insert>
<db:insert config-ref="MySQL_Configuration" doc:name="Update Metadata
Final State">
....
<db:insert>
</flow>
Problem Solved. I wrote a Java Component, implementing Callable and grabbed the ConsumerIterator. I then was able to use the iterator to obtain items in fetchSize. I then used Spring Jdbc since the data model is simple enough to transactionally save the data

Returning string as json in extJs

I am working on extJs 3.2.x
I have a simple function which returns a string.
public Object getRevenueCurrency(....) {
return "USD";
}
I have Jackson mapper to map the response type to JSON.
<bean name="jsonView" class="org.springframework.web.servlet.view.json.MappingJacksonJsonView">
<property name="contentType">
<!-- <value>application/json</value> -->
<value>text/html</value>
</property>
</bean>
An attempt to retrieve the data goes like this:
currencyStore = new Ext.data.JsonStore({
id:'currencystore',
url: 'xxxxxxx?action=getcurrency',
root: 'string',
listeners: {load: function(store) {
rev_currency=store.?????;
}
}
});
currencyStore.on('exception',function( store, records, options ){
alert('Exception was called');
},this);
Fiddler shows a response from server as :
{"string": "USD"}
Although I get no server or js exception,the exception alert is called.
1.How do i extract the currency value ?
2.What is a way to extract a meaningful information on the exception in the exception handler above?
Concerning your second question:
2.What is a way to extract a meaningful information on the exception in the exception handler above?
According to the docs for the exception event the signature and parameters are:
exception( store, type, action, options, response, arg )
By inspecting the parameters (e.g. by console.log(...)) you should retrieve some useful information.
I notice you have not configured any fields on your store, so when the reader takes your json respsonse its trying to find a field named 'string' to bind to.
Take a look at the ExtJS3 docs for the JsonStore -> http://docs.sencha.com/extjs/3.4.0/#!/api/Ext.data.JsonStore
The sample config shows you how the fields are defined, so your store should look like:
currencyStore = new Ext.data.JsonStore({
id:'currencystore',
url: 'xxxxxxx?action=getcurrency',
fields: ['string'],
listeners: {load: function(store, records, options) {
rev_currency=store.?????;
}
}
});
Note I have also changed the params to your load function handler, so the new record created from your json can be accessed using records[0]
You have configured the store by setting the root property which means the store's reader is expecting a root node in the json matching 'string'.
So the reader is actually expecting the below form of response.
{"string":[{"propertyname":"USD"}]}
Instead you could just take out the root property on your store config since all that's being returned is a flat object

Adding a 1 to many file upload to CRUD

My app has sales listing functionality that will allow the user to add 1 or more photos for the product that they want to sell.
I'm attempting to use the upload/filestore_image of ATK with a Join table to create the relationship - my models:
class Model_Listing extends Model_Table {
public $entity_code='listing';
function init(){
parent::init();
$this->addField('name');
$this->addField('body')->type('text');
$this->addField('status');
$this->addField('showStatus')->calculated(true);
}
function calculate_showStatus(){
return ($this->status == 1) ? "Sold" : "For Sale" ;
}
}
class Model_listingimages extends Model_Table {
public $entity_code='listing_images';
function init(){
parent::init();
$this->addField('listing_id')->refModel('Model_Listing');
$this->addField('filestore_image_id')->refModel('Model_Filestore_Image');
}
}
In my page manager class I have added the file upload to the crud:
class page_manager extends Page {
function init(){
parent::init();
$tabs=$this->add('Tabs');
$s = $tabs->addTab('Sales')->add('CRUD');
$s->setModel('Listing',array('name','body','status'),array('name','status'));
if ($s->form) {
$f = $s->form;
$f->addField('upload','Add Photos')->setModel('Filestore_Image');
$f->add('FileGrid')->setModel('Filestore_Image');
}
}
}
My questions:
I am getting a "Unable to include FileGrid.php" error - I want the user to be able to see the images that they have uploaded and hoped that this would be the best way to do so - by adding the file grid to bottom of the form. - EDIT - ignore this question, I created a FileGrid class based on the code in the example link below - that fixed the issue.
How do I make the association between the CRUD form so that a submit will save the uploaded files and create entries in the join table?
I have installed the latest release of ATK4, added the 4 filestore tables to the db and referenced the following page in the documentation http://codepad.agiletoolkit.org/image
TIA
PG
By creating model based on Filestore_File
You need to specify a proper model. By proper I mean:
It must be extending Model_Filestore_File
It must have MasterField set to link it with your entry
In this case, however you must know the referenced ID when the images are being uploaded, so it won't work if you upload image before creating record. Just to give you idea the code would look
$mymodel=$this->add('Model_listingimages');
$mymodel->setMasterField('listing_id',$listing_id);
$upload_field->setModel($mymodel);
$upload_field->allowMultiple();
This way all the images uploaded through the field will automatically be associated with your listing. You will need to inherit model from Model_Filestore_File. The Model_Filestore_Image is a really great example which you can use. You should add related entity (join) and define fields in that table.
There is other way too:
By doing some extra work in linking images
When form is submitted, you can retrieve list of file IDs by simply getting them.
$form->get('add_photos')
Inside form submission handler you can perform some manual insertion into listingimages.
$form->onSubmit(function($form) uses($listing_id){
$photos = explode(',',$form->get('add_photos'));
$m=$form->add('Model_listingimages');
foreach($photos as $photo_id){
$m->unloadDdata()->set('listing_id',$listing_id)
->set('filestore_image_id',$photo_id)->update();
}
}); // I'm not sure if this will be called by CRUD, which has
// it's own form submit handler, but give it a try.
You must be careful, through, if you use global model inside the upload field without restrictions, then user can access or delete images uploaded by other users. If you use file model with MVCGrid you should see what files they can theoretically get access to. That's normal and that's why I recommend using the first method described above.
NOTE: you should not use spaces in file name, 2nd argument to addField, it breaks javascript.

SalesForce Bulk API: Relationship between custom object and Account

I have a custom object in SalesForce called Deal, which is a child of the built-in Account object. I am trying to use the Bulk XML API to upload a batch of records, but I can't seem to figure out how to specify this relationship correctly. From the documentation it says that you should reference a custom object's relationships like so:
<Relationship__r>
<sObject>
<some_indexed_field>#####</some_indexed_field>
</sObject>
</Relationship__r>
If you have any idea how to specify a relationship to the Account object from a custom object I'd really appreciate it.
Added
The Deal object has the following 2 fields:
DealID
API Name - DealID__c
Data Type - Text(255)(External ID)(Unique Case Sensitive)
Account
API Name - Account__c
Data Type - Master-Detail(Account)
Request XML:
<Account__r>
<sObject>
<ID>0013000000kcWpfAAE</ID>
</sObject>
</Account__r>
Result XML:
<result>
<errors>
<message>Field name provided, Id is not an External ID or indexed field for Account</message>
<statusCode>INVALID_FIELD</statusCode>
</errors>
<success>false</success>
<created>false</created>
</result>
There appears to be a bug and you have to strip out all whitespace and newlines when dealing with reference objects.
Check out:
http://success.salesforce.com/ideaview?id=08730000000ITQ7AAO
From the docs
<RelationshipName>
<sObject>
<IndexedFieldName>rwilliams#salesforcesample.com</IndexedFieldName>
</sObject>
Everything looks good, but instead of using "ID" for the Indexed Field Name, you need to use "Account__c". That should take care of your issue.

Zend Many to Many Relationship

I want to retrieve all the data from 3 tables
users , properties and users_properties.
So I decided I would use the manytomanyRowset. But to my surprise I get the data from the properties and users_properties table but no data from the users table. Why is that? I need some columns from the users table is there a way to tell the manytomanyrowset function that I need the data from the current table as well?
this is my function
public function fetchRegisteredProperties()
{
$userTable = $this->getTable();
require_once APPLICATION_PATH . '/models/DbTable/UsersPropertiesDB.php';
require_once APPLICATION_PATH . '/models/DbTable/PropertiesDB.php';
$propertiesRowset = $table->fetchAll();
$allProperties = array();
foreach ($propertiesRowset as $row) {
$propertiesRowset = $row->findManyToManyRowset(
'Model_DbTable_Properties','Model_DbTable_UsersProperties');
$allProperties = array_merge($tempArray,$propertiesRowset->toArray());
}
return $allProperties;
}
thanks in adavance
I designed and coded the table-relationships features in Zend Framework.
The answer to your question is no, the findManyToManyRowset() method only fetches rows from the related table, it does not merge them into the corresponding Row object. The reason is that a Row object in ZF can save() itself back to the database, and if you add fields it won't know what to do with them.
So you should implement a custom Row object to hold both user fields and the collection of user properties -- store the user properties as a Rowset object.
Then extend __get() and __set() so that it knows how to map fields into the correct array when you read or write object properties. That is, if one tries to read or write a field that isn't part of the user row, it falls back to the user properties Rowset.
Also extend save() to save not only the current row, but also call save() on the Rowset of user properties.

Resources