Deluge: how to fetch Zoho CRM subform data - zoho

Hey I'm trying to get data from a Zoho CRM subform "PG_Info" to show up so I can merge it into a Zoho Writer template. When I try the code below it returns "null" for all entries. Any ideas?
r_Deal_Record = zoho.crm.getRecordById("Deals",Deal_Record_ID);
Subform = r_Deal_Record.get("PG_Info");
for each rec in Subform
{
field1 = rec.get("PG");
field2 = rec.get("SSN_PG");
field3 = rec.get("Ownership_Percent");
}
info field1;
info field2;
info field3;
Thank you

from your current code, the info's should be inside of the "for each" statement.

You would need to get the subform records using related list data.
Please refer to your API Name page in your Zoho CRM organization.
Find Deals module and then change the selection from Fields to Related Lists. In there you will find the API Name of your subform.
For example, if the API Name of your subform is PG_Info, then you will be able to pull it using below code.
// r_Deal_Record = zoho.crm.getRecordById("Deals",Deal_Record_ID);
// Subform = r_Deal_Record.get("PG_Info");
subformPG = zoho.crm.getRelatedRecords("PG_Info", "Deals", Deal_Record_ID);
for each rec in Subform
{
field1 = rec.get("PG");
field2 = rec.get("SSN_PG");
field3 = rec.get("Ownership_Percent");
// info moved to inside for, as the subform allowing multiple records
info field1;
info field2;
info field3;
}
Zoho Help

2 things to check:
#1. Double-check that the id number in Deal_Record_ID is correct and a record exists for it. Do this through the Zoho CRM user interface instead of through deluge-code.
#2. Display the full Subform variable with info Subform;. It may be 'null' (just like the record fields) but sometimes there is an error message or some data that is helpful to resolving the issue.

Related

How can I auto populate a field based on other fields with X++?

I am using D365 Finance and operations. I have a form and four fields in it. Every time I enter a new record of one of these three fields, their values should be concatenated and the combined text put to the 'Details' field which is the fourth field. I think I need to use onupdateevent for this but I do not know-how.
I used onmodifyingfield event handler and it works but only when I enter and save the second record. I mean I save record and auto-populate does not work but when I save the second record and refresh the page I can see the auto-populated field in the first record. Here is my codes;
[DataEventHandler(tableStr(InventSite), DataEventType::ModifyingField)]
public static void InventSite_onModifyingField(Common sender, DataEventArgs e)
{
MyTable myTable;
update_recordset mytable setting Details = MyTable.Field1 + ", " + MyTable.Field2;
I would really be appreciated if anyone can help me with this.
You can attach an event handler to Field1, Field2 and Field3 Modified events on the form DataSource and when it's triggered simply retrieve the current record, concatenate those values and write them into the Details field. The DataSource will then handle inserting or updating all those values into the database record:
[
FormDataFieldEventHandler(formDataFieldStr(InventSite, InventSite, Field1), FormDataFieldEventType::Modified),
FormDataFieldEventHandler(formDataFieldStr(InventSite, InventSite, Field2), FormDataFieldEventType::Modified),
FormDataFieldEventHandler(formDataFieldStr(InventSite, InventSite, Field3), FormDataFieldEventType::Modified)
]
public static void Field1_OnModified(FormDataObject sender, FormDataFieldEventArgs e)
{
// get the form DataSource
FormDataSource dataSource = sender.datasource();
// get current record
InventSite inventSite = dataSource.cursor();
// contatenate string values
str details = strFmt("%1, %2, %3", inventSite.Field1, inventSite.Field2, inventSite.Field3);
// update field value
inventSite.Details = details;
}
Note: I don't understand what MyTable myTable buffer is in your code example, but in this case by looking at DataEventHandler I suppose that all four fields are created in the InventSite table.

Find Data Using Laravel Framework

I want match data from "jobTable" based on job id then i got 5 data within this 5 data i have userId i want to show data from "userTable" based on userID. Then i will catch it on variable and i want to show it on my view then i will show it using loop.
If i do this below code it shows all data from my userTable not show based on matched JobID base UserId Details.
public function applyUser($jobId){
$applyUsers=ApplyInfo::where('job_id', $jobId)->get();
//5 rows found, with in this 5 rows everybody has userId I want to show data from user table based on this found userId and pass value a variable then i will loop it on view page.
foreach ($applyUsers as $applyUser){
$applyUsersDtials=Employee::find($applyUser->user_id)->get();
}
return view('front.user.apply-user-details', ['applyUsersDtials'=>$applyUsersDtials]);
}
//when i do that that time show all data based on my user table not show based on my JobId
First of all in your code $applyUsersDtials is a variable it should be an array. Next when you need to find a single row you just need to use find(). Try this-
public function applyUser($jobId){
$applyUsers = ApplyInfo::where('job_id', $jobId)->get();
$applyUsersDtials = [];
foreach ($applyUsers as $applyUser){
$applyUsersDtials[] = Employee::find($applyUser->user_id);
}
return view('front.user.apply-user-details',
['applyUsersDtials' => $applyUsersDtials]);
}

trigger on contact for counting of activities history and also updated on Account and opportunity object

field for number of Activities for each Contact, regardless of Type or Status.
Full Details: The requirement is to be able to create reports based on Contacts or account or Opportunities and see a “Summary” field for Total # of Activities associated with either Contacts, Accounts or Opportunities.
Note that we do not want to see a line for each activity, we want to see one line for the each contact or opp or account with the activity summary count.
Note: The original request also included the ability to have a unique activity count on reports
I haven't tested this code, but you could do something like this for an insert (you'd need to also cover updates and deletes). In this example, NumberOfActivites__c is your custom Task count field on the Contact object:
Map<Id,Integer> countMap = new Map<Id,Integer>();
List<Contact> contactList = new List<Contact>();
for (Task t : trigger.new){
//get id's of all contacts affected by the batch
Id w = t.whoId;
if (w.getSObjectType().getDescribe().getName() == 'Contact'){
//since there could be more than one task related to a contact
//in a batch, you would have to count them
if (countMap.keyset().containts(w)){
countMap.get(w) += 1;
} else {
countMap.put(w,1);
}
}
}
//get list of contacts to be updated
contactList = [Select Id, NumberOfActivities__c
From Contact
Where Id In :countMap.keyset()];
//modify contacts in list with new count
for (Contact c : contactList){
c.NumberOfActivites__c = c.NumberOfActivites__c + countMap.get(c.Id));
}
//do the update
update contactList;

Zoho Creator: Sort sub-form records in both Main Forms and Views/Reports

Zoho Creator is a great system for quickly creating simple cloud applications. I've run into a problem with sub-forms, though: currently, Zoho Creator does not provide functionality for sorting sub-form records by a specified column. Instead, it sorts records in the order in which they were added.
My sub-form is a Creator Form that's linked to another Creator Form (basically, 2 different tables). The forms are linked with a bi-directional lookup relationship.
I've seen and tried implementing these "hacks", but none of them work for my situation:
[Zoho Forums, "Subforms sorting rows"][1]
[Zoho Forums, "Hack to sort rows of a subform and pre-populate row fields that I want to preset"][2]
I also called Zoho tech support, and after looking at my application, they said that sorting sub-form records is not currently possible.
Any other ideas?
My tested solution is still a hack, but until Zoho implements a method to sort sub-form records via the GUI, this will have to do.
First, create a function that you can call from anywhere (e.g. when a new sub-form record is added or changed)--for details on that, go here: http://www.zoho.com/creator/help/script/functions.html
This function will first duplicate the sub-form records by the parent record ID (sorting by the appropriate column) and then delete all sub-form records that were inserted before the script started:
int SubFormRecords_SortByAnything_ReturnCount(int ParentRecordID)
{
scriptStartTime = zoho.currenttime;
for each rSubFormRecord in SubFormRecords [ParentFieldName = input.ParentRecordID] sort by FieldName1, FieldName3, FieldName2
{
NewSubFormRecordID = insert into SubFormRecords
[
FieldName1 = rSubFormRecord.FieldName1
FieldName2 = rSubFormRecord.FieldName2
FieldName3 = rSubFormRecord.FieldName3
];
}
delete from SubFormRecords[ (Series == input.ParentRecordID && Added_Time < scriptStartTime) ];
return SubFormRecords[ParentFieldName == input.EventID].count();
}
Once the above sorting function is in place (customized for your application), call it when appropriate. I call it when adding a record associated with the sub-form, or when I change the sorting column values.
That works well, and as long as you don't have complex logic associated with adding and deleting records, it should have minimal impact on application performance.
Please let me know whether that works for you, and if you have any better ideas.
Caveat: This solution is not suitable for forms containing additional sub-form records because deleting the records will delete linked sub-form values.
Thanks.
I have a a very simple workaround:
1) You have to add a Form Workflow
2)Record Event - Create OR Edit OR Create/Edit (As per your requirement)
3)Form Event - On successful form submission
4)Let Main_Form be the link name of the Main Form
4)Let Sub_Form be the Link name of the Sub Form (Not the link name you specify in the main form for the same sub form)
4)Let Field1 and Field2 are fields of subform on which you want to sort subform records
5)Let Link_ID be lookup field of Mainform ID in the subform
Workflow
1)Sub_Records = Sub_Form[Link_ID == input.ID] sort by Field1,Field2;
(sort by multiple fields, add asc/desc as per requirement)
2)delete from Sub_Form[Link_ID == input.ID];
3)for each sub_record in Sub_Records
{
insert into Sub_Form
[
Added_User = zoho.loginuser
Link_ID = input.ID
Field1 = sub_record.Field1
Field2 = sub_record.Field2
]
}
//Now you check the results in edit view of the main form

LINQ: Joining List<object> and dataset on a comma separated value field?

I am using C# and LINQ and trying to combine two sets of data. The first is a List of a specific type, lets call this Status (List) which is just a class with a bunch of properties one of which includes a comma separated value list of accounts. This is queried from the application database using a stored procedure so I have some flexability as to what is displayed here
For example:
class Status
{
...
public string Accounts {get; set;} (ie. "abcde, qwerty, asdfg")
public string Managers {get; set;}
...
}
The rest of the properties are irrelevant as this is the only field I am joining on.
The second "Accounts" data set is from a web service which I am calling to get a list of "Accounts" and the people associated with each account.
For example:
Account Manager SomeData MoreFields ...
------- ------------------- -------- ---------- ---
abcde Bob Marley Data MoreData ...
qwerty Fred Flinstone Data MoreData ...
So bascially I need to Create a list of Status objects with a CSV list of Manager(s) from the Accounts dataset in the Managers property of Status. Problem is I have no control over what is retruend in this dataset as it is a third party application. So I need to find some way to do this without modifying the "Accounts" data. Unless I do something in memory after getting the dataset from the web service.
I hope this makes sense and I thank you in advance!
What is this "dataset" of which you speak? I don't care where it come from -- I just care what kind of object it is in C#.
I'm going to assume that it's an ICollection, called "accounts"
Next, I'm going to assume that Managers is a CVS list much like Accounts.
Further, I'm only going to create one status object instead of a "list" of them, since you never say what separates one status from another.
var status = new Status();
status.Accounts = string.Join( ", ", from k in accounts select k.Account);
status.Managers = string.Join( ", ", from k in accounts select k.Manager);

Resources