Custom Field in Vtiger 7 - vtiger

Im trying to create a custom UIType and a followed this stack overflow without success, this is what i did:
Step1: update "modules\Vtiger\models\Field.php" and add new UIType as 222
I added the new UIType as follow in Field.php into public function getFieldDataType()
} else if($uiType == '222') {
$fieldDataType = 'json';
Step5: Register/insert new UIType in table vtiger_ws_fieldtype
enter image description here
But doesn't work

If you are trying to create new uitype just to store json then no need to create new uitype for it. You can create new text field to store json value in database
use json_encode to store json in newly created text field
use json_decode while fetching the value from db and use whenever needed.
And if you still want to create new uitype then you can follow the description and steps given here

Related

Updating The name of already existing field to something else in NiFi

Is there a way I can update the name of existing field in the CSV file to a new name. I know we can use updaterecord processor. But can someone tell me what config to set?
Current i am using CSVreader and CSVSetWritter with Recordpath value and adding a new property:
Property Value
/oldname ${field.name:replace('oldname','newname')}
It is not changing the name of the field. Can anyone help me here? thank you!
Keep your csv reader controller service with old name and csv Writer controller service with new name for the field.
Then swap the data from old name -> new name
UpdateRecord configs:
As Replacement Value Strategy
Record Path Value
Add new property as
/newname value as
/oldname
For more details refer to this article as i have swapped the data from id field to rename_id field.

Ember - Fetching live records with meta information

I have created a comment model and trying to fetch all comments records. But I need a meta info total comments which is getting as a separate attribute outside comments array.
I am using Ember store.query to fetch records from rest service(I tried store.findAll, but it is giving me only record array of comments in promise response. Is it possible to modify that?). I am getting the records with total comments(meta) while using store.query(), but that record array is not getting updated when we save new records.
After doing some analysis I found that we can use filter for loading the live record, but filter is now deprecated in Ember(Ember 2.5.1). From the documentation It is clear that we can use ember-data-filter for loading live record. But I am confused to use that addon(Mentioned like it has some memory leakage issue) and not sure whether I will get meta information from response. Is there is any other way to fetch live records with meta information from the response.
Anyone please suggest a solution
After doing some analysis, I found a solution to access meta data using store.findAll(). We can use typeMapFor in the findAll response to get the meta info in the response
store.typeMapFor(response.type)
Full code below,
store.findAll("comment").then(function(response) {
var meta = store.typeMapFor(response.type);
// your meta info will be in meta.metadata
// var totalComments = meta.metadata.totalComments;
});
And the response record array is liveRecords which will get updated automatically, if we save new records.
store.query("comment").then(function(response) {
var meta = response.get("meta");
// We will get meta like this but reponse record array is not a liveRecords
});
Response getting from store.query() is just a recordArray (not liveRecords) which will not get updated with new records
If you want an array of all records that updates as new records are populated you can use peekAll which returns a live record array.
Added Code sample:
loadRecords: function (){
this.set('allComments', store.peekAll('comment'));
this.store.findAll('comment');
},
recordCount: Ember.computed.alias('allComments.length')

Updating and creating a new instance at the same time

When a user updates an invoice form, i want to create a new invoice record with the updated attributes, but also change one or two fields of the old record and save it, too.
How would the outline of a controller action look like which could accomplish this?
Instead of a controller action i put the code in the model, using callbacks:
before_save do |rec|
if !rec.new_record?
attrb = rec.attributes.delete_if{|k, v| ["id"].include? k }
Book.create(attrb)
rec.restore_attributes
rec.year = rec.year + 2 # some custom change
true
end
end
I keep all attributes unless the 'id' (otherwise i get an error) for create a new record with the new attributes.
Then i restore the attributes of the existing record. I do some custom change before saving.
I am rather new with Rails but this seems pretty straightforward. As you mention the user is 'updating" an invoice, your controller view has probably been passed all the data available to the user for further change.
When submitting the form, your update action can easily update the current record data, as well as creating a new one on top of this
Though as it is automated, you need to make clear:
if a new invoice record is created each time an invoice record is
updated (thi can create a lot of copies of the same invoice)
how you make the old record an archive to avoid duplicates
can the 'additional" amendments be automated and easily processed through an algorithm...
Nested attributes made things a bit tricky. So in order to create new instances I had to use the dup method for both the resource and its nested items.
Generally, it is advisable to keep the controllers slim and make the models fat. Nevertheless, I have decided to include this code into my Invoices controller:
def revise_save
#contact = Contact.find(params[:contact_id])
#invoice = #contact.invoices.find(params[:invoice_id])
#invoice_old = #invoice.dup
#invoice.invoice_items.each do |item|
#invoice_old.invoice_items << item.dup
end
#invoice.datum = DateTime.now.to_date
# archive old invoice
# #invoice_old. ...
#invoice_old.save
# make old new invoice
#invoice.datum = Time.now
# ...
#invoice.update(invoice_params)
redirect_to invoices_path
end
Note that in this solution the currently edited (original) invoice becomes the new invoice, the old one is paradoxically created anew.
Thanks to #iwan-b for pointing me in the right direction.

how to verify email through link in rails4 application

How to verify email through link.
I have user edit profile and it is showing user email.I want to give one link to verify email.I do not what to do.
Add one column to your
User Model : email_verification and by default set to zero (0).
Then using persistence_token create a URL and sent to that specific email address. If you dnt have persistence_token as column in your User model then you can add custom column of your choice like verify_email_token as column name and stored 50 random string.
Using
o = [('a'..'z'),('A'..'Z'),('0'..'9')].map{|i| i.to_a}.flatten
string = (0...50).map{ o[rand(o.length)] }.join
URL example :
http://www.yoursitename.com/VerifyEmailAddress/?token=persistence_token ;
When user click on that link, internally call function like VerifyEmailAddress and in that method update email_verification column by one (1).

Django, Tastypie and retrieving the new object data

Im playing a little bit with heavy-client app.
Imagine I have this model:
class Category(models.Model):
name = models.CharField(max_length=30)
color = models.CharField(max_length=9)
Im using knockoutjs (but I guess this is not important). I have a list (observableArray) with categories and I want to create a new category.
I create a new object and I push it to the list. So far so good.
What about saving it on my db? Because I'm using tastypie I can make a POST to '/api/v1/category/' and voilĂ , the new category is on the DB.
Ok, but... I haven't refresh the page, so... if I want to update the new category, how I do it?
I mean, when I retrieve the categories, I can save the ID so I can make a put to '/api/v1/category/id' and save the changes, but... when I create a new category, the DB assign a id to it, but my javascript doesn't know that id yet.
in other words, the workflow is something like:
make a get > push the existing objects (with their ids) on a list > create a new category > push it on the list > save the existing category (the category doesnt have the id on the javacript) > edit the category > How I save the changes?
So, my question is, what's the common path? I thought about sending the category and retrieving the id somehow and assign it to my object on js to be able to modify it later. The problem is that making a POST to the server doesn't return anything.
In the past I did something like that, send the object via post, save it, retrieve it and send it back, on the success method retrieve the id and assign it to the js object.
Thanks!
Tastypie comes with an always_return_data option for Resources.
When always_return_data=True for your Resource, the API always returns the full object event on POST/PUT, so that when you create a new object you can get the created ID on the same request.
You can then just read the response from your AJAX and decode the JSON (i dont know about knockout yet).
see the doc : http://readthedocs.org/docs/django-tastypie/en/latest/resources.html?highlight=always_return_data#always-return-data
Hope this helps